Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Start date cannot be past date

Deepthi13
Tera Expert

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

}

1 ACCEPTED SOLUTION

yes. 

 

Date type variable on catalog form. 

 

find_real_file.png

 

Catalog UI Policy 

 

find_real_file.png

 

find_real_file.png

 

Result: i tried to select the 27th may and it gave me an alert. 

 

find_real_file.png

View solution in original post

14 REPLIES 14

Harsh Vardhan
Giga Patron

adding one thread here. kindly have a look on that script. 

 

Start Date cannot be in the past

Hi Harsha,

this is not workign for i did as it is please check below code also

find_real_file.png

function onCondition() {
g_form.setValue('_loaner_date', '');
alert("Start date cannot be past date");
}

the field is date type or date/time type?

where are you validating ? on portal ? is yes then make sure UI type should be set as ALL

i am checking in normail back office only but UI type is ALL only. 

it is date field