- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2018 08:11 AM
How can I restrict a date field from allowing to enter future date?
Thank you,
Sarah
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2018 08:15 AM
Try this On Change Client Script for your date field that you want to check:
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;
}
}
Regards
Paul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2018 08:15 AM
Try this On Change Client Script for your date field that you want to check:
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;
}
}
Regards
Paul

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2020 01:54 AM
Thank you for your code
i used it , 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2018 08:37 AM
Thank you! That worked!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2018 08:10 PM
I am getting 'getDateFromFormat' is undefined error in service portal. can you please help me with the code that works in service portal?