- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-28-2019 02:16 AM
hi team,
i am trying client script as below please correct if any thing wrong here
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
var date_obj = new Date(getDateFromFormat(newValue,user_date_time_format));
var current_date=new Date();
if(date_obj<current_date){
g_form.showFieldMsg('Date','Date should not be past value',error,true);
}
else{
g_form.setValue('Date',current_date);
}
//Type appropriate comment here, and begin script below
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-28-2019 03:54 AM
yes.
Date type variable on catalog form.
Catalog UI Policy
Result: i tried to select the 27th may and it gave me an alert.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-28-2019 03:49 AM
no i am doing in client instance only 😞
is that date field u tried in ur instance?
could you please provide ur screen shots

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-28-2019 03:54 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2021 05:47 AM
How to handle the same on the list view for Variable?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-28-2019 04:34 AM
Hi Deepthi,
Write a script include with client callable is true
var MyDateTimeAjax = Class.create();
MyDateTimeAjax.prototype = Object.extendsObject(AbstractAjaxProcessor, {
nowDateTime: function () {
return gs.now();
},
type: 'MyDateTimeAjax'
});
Write a Onchange client script with below code:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var ajax = new GlideAjax('MyDateTimeAjax');
ajax.addParam('sysparm_name','nowDateTime');
ajax.getXML(checkdate);
function checkdate(response){
var currentDate = response.responseXML.documentElement.getAttribute("answer");
var startDate90 = g_form.getValue('return_date'); //Change the required date field name
if(startDate90 < currentDate){
alert('You cannot select a date in the past.');
g_form.clearValue('return_date');
}
}
}
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-23-2020 07:07 AM
Okay, so this is for date... but what do we do to restrict selection of past time?
for Date/Time field.