Prevent catalog submission based on date field in text box (string field) in MRV
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2022 07:40 PM - edited 11-17-2022 07:45 PM
Hi,
I am populating date field in string field in MRV and want to prevent submitting the form if any of the date is more than 365 days with today's date and if it falls less than 365 days then form should be submitted. I have written onsubmit client script but Its not checking for all date fields (in rows)
function onSubmit() {
var today = new Date();
//today.setHours(0,0,0,0);
var startDTe = g_form.getValue('course_completed_date');
//alert(startDTe);
var startDateNum = getDateFromFormat(startDTe, g_user_date_format);
var coursedate = today - startDateNum;
alert(coursedate);
var dayDifference = coursedate / (1000 * 60 * 60 * 24);
// alert(dayDifference);
if (dayDifference > 365) {
return false;
}
return true;
}
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2022 01:04 PM - edited 11-21-2022 01:10 PM
You don't need the return true line as that won't do anything - return true is the default unless you meet a condition where it should return false to prevent the submit. Alert on today just to make sure that is what you expect, and also alert on mrvs before the parse so you can see what it is trying to parse. You should never name a variable, variable set, or function with reserved words, so also try changing your MRVS internal name to something more than 'date' like even 'date_mrvs'.