I’m using input text field to input numbers only. I can’t use input type="number" because i probably use the decimal or (.) characters
Example of expected result:
- whole numbers
- numbers with decimal
- restricted alphabets
If possible, only decimal character are allowed, the rest will restricted also in special character.
3
Answers
HTML
In the attribute step , you can define your steps like .01.
jQuery
In case you are looking for a regex that allows only numbers with an optional 2 decimal places
HTML:
JS / jQuery:
using jquery validation is easily possible for input
Here you go. Regex check for input, allow only numeric value and decimal. And if condition check, it’s only take one decimal.
Example: