I have an input tag of type text.
The user is supposed to enter a float or int, greater than 4. How to I verify that the user has not entered any non-numeric characters ? Decimal points are ok:
For example:
How do I do this? Parsing each and every character in the text box seems clumsy, and I'm don't know think I can do this with a regex. Any suggestions ?
Use parseFloat()
:
Here's a JSFiddle example: http://jsfiddle.net/HbqF3/3/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.