Need to validate the end date is not before the start date onSubmit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2022 11:01 AM
When a customer is requesting a report for a period of time from start date to end date. I need to validate onSubmit that the end date is not before the start date and it needs to not allow it to be submitted until corrected.
My variable field names - 'time_period_of_interest_start_date' and 'time_period_of_interest_end_date'

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2022 03:02 AM
Hi,
Would appreciate a screenshot of variable definition.
Also, what would the alert show when onSubmit script is changed as follows.
function onSubmit() {
try {
var startDate = getDateFromFormat(g_form.getValue('time_period_of_interest_start_date'), g_user_date_format);
var endDate = getDateFromFormat(g_form.getValue('time_period_of_interest_end_date'), g_user_date_format);
alert('start:' + startDate + ' endDate:' + endDate + ' date format:' + g_user_date_format);
if (startDate > endDate) {
g_form.clearMessages();
g_form.addErrorMessage('End date should be after start date');
return false;
}
} catch (e) {
alert(e.message);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2022 10:01 PM
I put this code into OnSubmit and I got a box to popup but it did not give an error message.
These are the variables.
This was the error