- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
22 hours ago
Hi All,
user should not select thedate before 90 days from the current date
for example : today date is 15 oct 2025 than user should not select before 17 july or 16 july but he can select 10 aug 1 sept or future date also . this script is not working in the catalog item , Can anyone help me :
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
22 hours ago
I'd recommend switching to the no-code approach as documented by @Mark Roethof in the following article:
No Code date validations through (Catalog) UI Policies - ServiceNow Community
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
22 hours ago - last edited 22 hours ago
Hi @chandan2212
In Service Catalog, the newValue for a date field is not always in a format (yyyy-MM-dd) that new Date() can parse correctly in all browsers or UI frameworks.
It often returns Invalid Date, so your comparison (selectedDate < ninetyDaysAgo) silently fails.
Replace:
var selectedDate = new Date(newValue);
By:
var selectedDate = new Date(newValue + 'T00:00:00');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
22 hours ago
Hi @chandan2212,
have you checked what date format is given and what is required in the code?
When you submit the form, what format do you see in the variable afterwards?
Is it "15.10.2025", "2025-10-15", or any other....?
You might need to use getByFormat('DD-MM-YYYY'); //or to select what date format is used
Also, if you will have it for onChange it will only display info message but it will let the user submit, so you can keep this to inform them but to abort submission you will need to achieve it by onSubmit CCS...
/* If my response wasn’t a total disaster ↙️ ⭐ drop a Kudos or Accept as Solution ✅ ↘️ Cheers! */

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
22 hours ago
I'd recommend switching to the no-code approach as documented by @Mark Roethof in the following article:
No Code date validations through (Catalog) UI Policies - ServiceNow Community