Client script for current and future dates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2023 09:09 AM
I need client script for allowing only current and future dates.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2023 09:14 AM
function onLoad() {
var dateField = g_form.getControl('date_field_name');
var today = new Date().setHours(0, 0, 0, 0);
dateField.setMin(today);
}
function onSubmit() {
var dateFieldValue = g_form.getValue('date_field_name');
var selectedDate = new Date(dateFieldValue).setHours(0, 0, 0, 0);
var today = new Date().setHours(0, 0, 0, 0);
if (selectedDate < today) {
g_form.addErrorMessage('Please select a current or future date.');
return false;
}
return true;
}
//Replace "date_field_name" with the actual name of your date field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2023 09:18 AM
You can achieve this functionality using UI policy also. I made an example on created field you can mention your field name in the filter
If my answer solved your issue, please mark my answer as ✅Correct & 👍Helpful based on the Impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2023 05:34 AM
Hey Prince,
I wanted to let you know that this method doesn't work on a custom workspace.
Thanks,
Gonzalo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2023 10:00 AM
Please accept the solution if it works for you!