- 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:16 PM
Hi.
How about changing the variable type to Numeric scale instead?
Otherwise you need to perform some additional logic (onchange script) to validate that the number entered is max 25.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-18-2021 01:34 AM
I need to set it from 1-999 🙂

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-18-2021 01:42 AM
Then I would go with
To try and learn about regex, you can try this page: https://regexr.com/

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2021 11:25 PM
Hi there,
So your question is a Regex for 0 to 25? Or is your question different?
If 0 - 25:
\b([0-9]|1[0-9]|2[0-5])\b
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