We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

How to Restrict Date field that user should able to enter date between 1990-200 year.

Shweta Kasbe1
Tera Contributor

How to Restrict Date field that user should able to enter date between 1990-200 year if he enters 2001 its should not able to create record. and also throw error invalid date

 

7 REPLIES 7

Not applicable

Hi @Shweta Kasbe ,

use UI policy than a client script because of the execution order in which they both run, UI Policy runs first.

Try something like below, just replace the conditions with your own required conditions:

Create a new UI policy on the date field as below   :

find_real_file.png

Click on the advance checkbox, in the script part write the following code :

function onCondition() {

alert('End date cannot 6 months from current date');

g_form.setValue('u_end_date','');

}

find_real_file.png

Limit date selection in date field

Find difference between two dates

Date Validation in ServiceNow

Client script date validation

Client script to validate start/end date fields

Mark my answer correct & Helpful, if Applicable.

Thanks,
Sandeep

On which table should i create ui policy?

Not applicable

The table where you have this form, you will use that table to write this UI policy.

Mark my answer correct & Helpful, if Applicable.

Thanks,
Sandeep

Ankur Bawiskar
Tera Patron

Hi,

where is this validation required?

On form?

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader