- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2018 11:15 PM
Hi every one
My requirement is
In a form i created a Date type variable and suppose i select any Date before today's date then only form will be submit.other wise it shows error message.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2018 01:11 AM
Hi,
Please write an onSubmit script as below,
function onSubmit() {
var dat = g_form.getValue('u_current_time'); //Put in the field name
var reqDate = new Date(dat);
var today = new Date();
if(reqDate.getDate() > today.getDate()) {
alert('The Date selected is in the future');
return false;
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2018 11:23 PM
Hi,
You have to create a Onchange Client script on this Date field and use GlideAjax which will call script include and return the difference from this date field and current date time.
I will provide you a script in a while.
Thanks,
Ashutosh Munot

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2018 12:27 AM
Hey hi
//Write before business rule on your table.
(function executeRule(current, previous /*null when async*/) {
var dat = current.u_opened_at;
var gdt = new GlideDateTime();
var today = gdt.getDate();
// gs.addInfoMessage(dat);
// gs.addInfoMessage(today);
if(dat < today) {
gs.addInfoMessage('The Date selected is in the past');
current.update();
}
else
current.setAbortAction(true);
gs.addInfoMessage('ERROR!!Date is in invalide state!!');
})(current, previous);
this is working well on my instance.
Please mark correct if helpful.
Regards,
Ashvini.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2018 01:11 AM
Hi,
Please write an onSubmit script as below,
function onSubmit() {
var dat = g_form.getValue('u_current_time'); //Put in the field name
var reqDate = new Date(dat);
var today = new Date();
if(reqDate.getDate() > today.getDate()) {
alert('The Date selected is in the future');
return false;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2018 04:10 AM
Thanks Harneetsital