- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2019 11:00 PM
Hi All,
Can any one please assist me to write a regex to validate if value entered is in between 5 to 1000.
Tried few things but it's not working in script.
Many thanks!
-Ruchi
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-06-2019 10:56 PM
Hi Ruchi,
If you want to use RegEx to validate those limits you can try:
var pattern = /^([5-9]|[1-9][0-9]|[1-9][0-9][0-9]|1000)$/g;
alert(pattern.test("999"));
Tried it for few combinations, seems to be working fine. Try that out and see if it works for you.
Hope this helps!
Cheers,
Manish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-06-2019 10:19 PM
Hi Ruchi,
so you can use this first to check whether it is an integer or not and then compare the range
if(value >5 && value < 1000){
// ok
}
else{
// invalid
}
}
else{
alert('Please put only integer values');
}
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-06-2019 10:56 PM
Hi Ruchi,
If you want to use RegEx to validate those limits you can try:
var pattern = /^([5-9]|[1-9][0-9]|[1-9][0-9][0-9]|1000)$/g;
alert(pattern.test("999"));
Tried it for few combinations, seems to be working fine. Try that out and see if it works for you.
Hope this helps!
Cheers,
Manish