- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2021 11:04 PM
Hi, Everyone.
I used single line text variable and changed the validation regex to Number.
However, I'm not sure how to set a number range, for example the maximum person can be in a room is only 25.
Can someone help?
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2021 11:41 PM
Hi Leo,
This has no limit on the number of digits.
If you want to restrict or set the range you will have to use a OnChange Client Script:-
The logic you should use is below:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return }
var regExTest = /^[1-9][0-9,]*$/;
if(!regExTest.test(newValue)){
alert("Please enter valid characters"); g_form.setValue('urfieldname', '');
} }
Please mark my answer as Correct & Helpful, if applicable.
Thanks
Sandeep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2021 11:41 PM
Hi Leo,
This has no limit on the number of digits.
If you want to restrict or set the range you will have to use a OnChange Client Script:-
The logic you should use is below:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return }
var regExTest = /^[1-9][0-9,]*$/;
if(!regExTest.test(newValue)){
alert("Please enter valid characters"); g_form.setValue('urfieldname', '');
} }
Please mark my answer as Correct & Helpful, if applicable.
Thanks
Sandeep

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2021 11:49 PM
In case you wonder where to create your own validation regex:
I do believe this should be your first go-to instead of Catalog Client Script.
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
2020, 2021 ServiceNow Community MVP
2020, 2021 ServiceNow Developer MVP
---
LinkedIn
Community article, blog, video list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field