Click here to Skip to main content
15,921,841 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)

these are valid

these are not valid

I tried ^\d{0,9}(\.\d{0,9})?$ but it didnt work
Updated 11-Sep-15 5:25am
Sergey Alexandrovich Kryukov 11-Sep-15 11:44am    
Because your regular expression does not even contain the figure 6... :-)
Also, why doing so? Validation of floating-point data is much more complex.
Patrice T 11-Sep-15 18:47pm    
What is the usage ?

Try changing the 9 to a 6:
Share this answer
Please see my comment to the question. Is looks like validation of some floating-point input. Who cares how many digits are there. You only need to take care of valid format, and, on top of it, probably a valid range. But how?

Simple. Use parseFloat:[^].

Failure will be indicated by null value returned. If parsing is successful, you get floating-point numeric object which you can additionally check for the expect range of values. That's all.

Alternatively or additionally, you can use masked text box for input. Please see, for example:[^].

Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900