Validate a date field AND check that it falls within a certain range?

scottn
Mega Expert

This forum has been incredibly helpful to me, so here I am again, with another question.   🙂

I'm trying to test whether a user-entered date in a record producer falls within a specific range. Here is the code I have in the "What it will contain" scripting section of the record producer (ignore the UtilityBill section):

servicenowdate.JPG

This code works great if the user enters a date. But if the user puts in random characters or random numbers, the code thinks it falls within the range as well.

Any thoughts on ways I can make sure the user-entered date is a true date AND falls within my range?

Thanks for any help in advance!

2 REPLIES 2

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Scott,



You can validate the date with the help of catalog client script. Please refer the below thread for reference.


https://community.servicenow.com/thread/165393


matthew_magee1
Giga Guru

Hey Scott,


Why not use variable type 'Date' so the user is forced to select a properly formatted date? This way you are not having to mess w/ random characters and such