How to restict the value

chandan31
Tera Contributor

Hi All ,

 

I  need to create regex to restrict the value from 0 to 30.0 . but it should not allow more than 30.1 . that field is numeric value 

Thanks,

Chandan

1 ACCEPTED SOLUTION

As said, before... please share your script if it's not working. This regex is correct for what you asked Only allow for values 0 until (and including) 39.0

 

PeterBodelier_0-1702050743145.png

 


Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.

View solution in original post

8 REPLIES 8

Sorry, missed a bit 🙂

 

 

/^(?:39(\.0)?|3?[0-8](\.[0-9])?|2?[0-9](\.[0-9])?|1?[0-9](\.[0-9])?|0?(\.[0-9])?)$/

 


Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.

not working

As said, before... please share your script if it's not working. This regex is correct for what you asked Only allow for values 0 until (and including) 39.0

 

PeterBodelier_0-1702050743145.png

 


Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.

If it is a numeric field then why dont you just try below:

 

if(g_form.getValue("numeric_field_name") < 39) then do something.

 

Try this. Regex operation is needed on string fields. As it is already a number field so people will write only numbers on it.

 

If still doesnt work try using parseInt(numeric field value);

Regards,Shamma Negi