Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a week ago
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var s=g_form.getValue('u_sdate');
var e=g_form.getValue('u_edate');
var flag=0;
if(e<s)
{
g_form.showFieldMsg('u_sdate','Start date must be greate than start date');
flag=1;
}
if(flag==1)
{
g_form.submit(false);
}
else{
g_form.submit();
}
} i want to cancel submission until start date must less than end date using single client script
Solved! Go to Solution.
1 ACCEPTED SOLUTION
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a week ago
you can use single onSubmit client script for this
function onSubmit() {
//Type appropriate comment here, and begin script below
g_form.hideErrorBox('u_sdate');
g_form.hideErrorBox('u_edate');
if(g_form.getValue('u_sdate') != '' && g_form.getValue('u_edate')){
var start = new Date(g_form.getValue('u_sdate')).getTime();
var end = new Date(g_form.getValue('u_edate')).getTime();
if(end < start){
var message = 'Please give valid start and end dates';
g_form.showErrorBox('u_sdate', message);
g_form.showErrorBox('u_edate', message);
return false;
}
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Regards,
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a week ago
Thank you , it works😇