Restrict user to select a time in the future.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2020 08:45 PM
In my incident form, there is a field of 'date/time' format. Date validation(i.e restriction on selecting a date in the future) has been done. Kindly help on how to restrict a user to select a time in the future.
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2020 08:50 PM
Hi Ramya,
You can do something like on an onChange client script on the change of that date field.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//current date
var currentDateObj = new Date();
var currentDateStr = formatDate(currentDateObj, g_user_date_format);
var currentDateNum = getDateFromFormat(currentDateStr, g_user_date_format);
var startDateNum = getDateFromFormat(newValue, g_user_date_format);
if (startDateNum > currentDateNum) {
alert(“Date is in the future”);
g_form.clearValue("your_date_field");
return false;
}
}
If you want to see example you can refere below link where user has achieved the same.
Mark my ANSWER as CORRECT and also HELPFUL if it helped.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2020 09:02 PM
I want to restrict the user to select 'time' in the future. For example, if its 11:00AM when the user is raising a incident, he cannot select a time at 4:00PM on the same day. He should be able select a time before 11:00AM but not after 11:00AM.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2020 09:15 PM
Have you tried the code yet
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2020 09:27 PM
yes, i tried.. but it is not working.