- 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-01-2019 11:11 PM
try this
function onChange(control, oldValue, newValue, isLoading) {
if(isLoading || newValue == ''){
return;
}
var pattern = /^([5-9][5-9]{0,2}|1000)$/; // number between 5 to 1000
if(!pattern.test(newValue)){
g_form.showFieldMsg('number', 'Please enter a number between 5 to 1000', 'error');
}
}
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2019 11:19 PM
Hi Harish,
This is working fine.
Thanks!
-Ruchi

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2019 11:47 PM
Glad it worked for you. Also mark the appropriate answer as correct
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-06-2019 10:16 PM
Hi Harish,
I tried with few values and noticed it is not working as expected. I can only enter values that doesn't contain numbers 0-4, eg 555 would be accepted but not 554 or 500.
Regards,
Ruchi