Please tell me what regular expression should i use to validate cricket overs in textbox. like it can be 5.1, 5.2,5.3,5.4,5.5 but it should not contain fraction value greater than .5 ,also the values should be numeric only (float and int)
Thanks
Please tell me what regular expression should i use to validate cricket overs in textbox. like it can be 5.1, 5.2,5.3,5.4,5.5 but it should not contain fraction value greater than .5 ,also the values should be numeric only (float and int)
Thanks
You should use this:
If you also want fractions like
.2
instead of0.2
, use this:Explained:
Your version,
[0-9]+(\.[0-5])?
does not work unfortunately, because, for example/[0-9]+(\.[0-5])?/.test("0.8")
yields true.