End Date and Time can't be before Start end date and time
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2022 12:11 PM
I have two date and time fields, start and end. I would like end date/time field not be before start date/time field. Can someone please help with an onChange client script as i am struggling.
Thank you,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2022 12:15 PM
Hello Jen you can do this in client script
g_form.hideFieldMsg('end_date');
var dtStartForm = g_form.getValue('start_date');
var dtStart = getDateFromFormat(dtStartForm,g_user_date_time_format);
if (dtStartForm != '') {
var dtEndForm = g_form.getValue('end_date');
var dtEnd = getDateFromFormat(dtEndForm, g_user_date_time_format);
//g_form.addInfoMessage('Start Date : ' + dtStart + ' : End Date : ' + dtEnd);
if (dtEnd < dtStart) {
g_form.showFieldMsg('end_date', 'Planned end date cannot be before start date', 'error');
}
}
Hope this helps
MARK MY ANSWER CORRECT IF THIS HELPS YOU
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2022 12:44 PM
Thank you for your help, i did the following and its not working:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//Type appropriate comment here, and begin script below
var dateFormat=g_user_date_time_format;
var D_one = g_form.getValue("u_date_time_first_reported");
var D_two = g_form.getValue("u_date_time_resolved");
var dateOneFormat = getDateFromFormat(D_one , g_user_date_time_format);
var dateTwoFormat = getDateFromFormat(D_two , g_user_date_time_format);
if(dateTwoFormat >dateOneFormat )
{
alert('End date cant be less than start date');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2022 12:49 PM
hello jen my bad gave the wring script i think its better to use the glide ajax
can you use this script by creating a script include
refer this below link and check for saprem.d answer for the script
Hope this helps
Mark my answer correct if it helps you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2022 12:50 PM
Hello jen i think its better to use the glide ajax
can you use this script by creating a script include
refer this below link and check for saprem.d answer for the script
Hope this helps
Mark my answer correct if it helps you