Regex for decimal validation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2021 09:44 PM
I have created SingleLineText Field on Record Producer name as Temperature. I Want to achieve to validate this field from regex which takes only integer and with 2 decimal digits. And also it takes a value within a range from 95.0 to 106.0.
If the entered temperature is not within this range display Please enter a valid temperature in the range of 95.0 – 106.0 degrees Fahrenheit.
Ex., If the user enters 95 only it should take value. And also it should take up to 106.0
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2021 09:57 PM
Hii Bharati,
You can write below script to achieve numbers only
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var regexp = /^[+]?\d*$/;
if(!regexp.test(newValue)){
alert('Please enter numeric value');
g_form.setValue('v_sec_review_unknown','');
}
}
Please mark it as helpful or correct if it helps you.
Thanks ,
Rupali Bondar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2021 10:27 PM
Hi,
Please use below script:
if (isLoading || newValue == '') {
return;
}
var regexp = "^(?:106(?:\.0)?|[95-105](?:\.[0-9])?|0?\.[1-9])$";
if(!regexp.test(newValue)){
alert('Please enter numeric value');
g_form.setValue('v_sec_review_unknown','');
}
}
Thanks,
Anil Lande
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2021 10:25 PM
Thank you!, I want to achieve a number with 2 decimal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2021 11:37 PM
Hello,
Could you try the below expression it will be allowed you to enter max 2 decimal places
^\d+\.\d{0,2}$ //where "2" is the maximum allowed decimal places.
Check below links for your refernece
https://stackoverflow.com/questions/4690986/regex-needed-to-match-number-to-exactly-two-decimal-places
https://stackoverflow.com/questions/308122/simple-regular-expression-for-a-decimal-with-a-precision-of-2/308216
https://forums.asp.net/t/1909870.aspx?Regular+expression+to+allow+a+number+upto+2+decimal+places
Pelase mark my answer correct or helpful if it helped you in any way.
Thank you