How to Restrict Date field that user should able to enter date between 1990-200 year.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2022 12:55 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2022 01:11 AM
Hi
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 :
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','');
}
Limit date selection in date field
Find difference between two dates
Client script to validate start/end date fields
Mark my answer correct & Helpful, if Applicable.
Thanks,
Sandeep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2022 01:42 AM
On which table should i create ui policy?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2022 07:56 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2022 01:51 AM
Hi,
where is this validation required?
On form?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader