- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2023 04:37 AM - edited 05-19-2023 02:25 AM
End date is greater than OR equal to the Start date, I have used below script its not working for Equal function.
only working on the greater than function.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var end = g_form.getValue('start_date');
var start = g_form.getValue('end_date');
if (end >= start) {
alert("Start date is greater than OR equal to End date.");
g_form.clearValue('end_date');
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2023 02:35 AM
same script just modify
1) onChange client script on End date
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
g_form.hideErrorBox('start_date');
g_form.hideErrorBox('end_date');
if(g_form.getValue('start_date') != '' && g_form.getValue('end_date')){
var start = new Date(g_form.getValue('start_date')).getTime();
var end = new Date(g_form.getValue('end_date')).getTime();
if(end < start){
var message = "Start date should be greater than OR equal to End date.";
g_form.showErrorBox('end_date', message);
g_form.clearValue('end_date');
}
}
}
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2023 02:35 AM
same script just modify
1) onChange client script on End date
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
g_form.hideErrorBox('start_date');
g_form.hideErrorBox('end_date');
if(g_form.getValue('start_date') != '' && g_form.getValue('end_date')){
var start = new Date(g_form.getValue('start_date')).getTime();
var end = new Date(g_form.getValue('end_date')).getTime();
if(end < start){
var message = "Start date should be greater than OR equal to End date.";
g_form.showErrorBox('end_date', message);
g_form.clearValue('end_date');
}
}
}
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2023 02:35 AM
Please mark my response as correct as my script worked for you.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader