How can I restrict input to a text-box so that it accepts only numbers and the decimal point?
相关问题
- Views base64 encoded blob in HTML with PHP
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- void before promise syntax
- Keeping track of variable instances
It will allow only numeric and will let you put "." for decimal.
Here is one more solution which allows for decimal numbers and also limits the digits after decimal to 2 decimal places.
Extending the @rebisco's answer. this below code will allow only numbers and single '.'(period) in the text box.
alternative way to restrict input to a text-box so that it accepts only numbers and the decimal point is to use javascript inside the html input. This works for me:
--Accepts--
9
9.99
--Do not accept--
9.99.99
ABC