- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2015 04:00 AM
I've seen this in the community where this is working for others, but it's not working for me. What do I have wrong? I get no error message. It's just ignored.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if(newValue != '')
{
var reqDate = new Date(getDateFromFormat(newValue, g_user_date_format));
var today = new Date();
if(reqDate.getTime() <= today.getTime()) {
alert('Date must not be in the past.');
g_form.setValue('sDate', '');
}
}
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2015 07:45 AM
Hi Karen,
You are just comparing the time. You should first compare date and then time. Or both at the same time.
Try with the below shown code-
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue == '') {
return;
}
// if(newValue != '') don't need this as you already have checked above
// {
var reqDate = new Date(newValue);
var today = new Date();
if(reqDate <= today){
alert('Date must not be in the past.');
g_form.setValue('closed_at', '');
}
// }
}
Thanks,
Tanaji
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2018 12:54 PM
Hi Tanaji,
How do you set the default for a couple minutes past when the form loads? Can we do that within the same script?
Thanks,
Mike

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2018 05:49 AM
var reqDate = new Date(getDateFromFormat(newValue, g_user_date_time_format));