I cannot get the "End date" before "start date" client script to work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-08-2017 01:52 AM
This is my current code for a catalog client script:
function onSubmit()
{
//g_form.addInfoMessage("Before error");
var datefrom = g_form.getValue('u_it_email_ooo_datefrom');
var dateto = g_form.getValue('u_it_email_ooo_dateto');
if(datefrom > dateto)
{
g_form.clearMessages();
g_form.addErrorMessage("End date cannot occur before start date.");
return false;
}
}
It works fine when the end date is before the start date, but only when they are in the same month.
When I change the end date to a day in the month before the start date, it allows me submit. Can anyone help? This is quite urgent because i have a meeting with my manager to put this through to our live system today and cannot get it to work properly!! Please help!!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2018 09:17 PM
Cheers Darren 🙂
Raj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-29-2018 08:07 AM
This works for me on Service Portal
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
g_form.hideFieldMsg('end_date', true);
var startDate = g_form.getValue('start_date');
if ( newValue < startDate){
g_form.showFieldMsg('end_date',"End date can't be prior to Start date ",'error');
}
//Type appropriate comment here, and begin script below
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2018 06:05 AM
Have you modified this script to account for users with a different date/time format? Someone with a format of dd/MM/yyyy will receive the error message if the start/end dates span multiple months (Example: Start Date = August 30: 30/08/2018, End Date = September 1: 01/09/2018)