- 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
07-25-2015 09:34 AM
sorry - this is the first question I've posted out here. How do I mark the response was the correct answer?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2015 09:35 AM
No Problem. You should be seeing the correct answer button near the response..You have to click on that.
Please let me know if you have any questions.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2015 09:19 AM
Great
Please see my last comment to reset the variable. You need to change that line as well in your code.
Please mark the correct/helpful answers.
Thanks,
Tanaji

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2015 09:21 AM
I don't think we need to use variables in client side to set the Value..All you need is the name of the variable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2017 11:27 AM
Hi Pradeep,
hope you can help pls.
I have a date variable in a catalog item that i want to put a validation on.
Date type is "date"
So Basically, user selects date and calendar pops up, they select the date. if the date selected is less than 5 working days then i want an error or alert to pop up.
I have tried modifying the above script but it's not working.
Are you able to help pls?
Thanks in advance