'Angular input field type number should allow only numbers from 0-9
Having an input field where the user will enter the amount in it. i do want to restrict the users from entering decimal points. Eg : if user tries to enter 121.2 , i should not allow him to place '.'(decimal point) character in the input box.
The below sample works on web but the same is not working on android mobile numberic keypad.
Sample-1
<input (keydown)="if(event.key==='.'){event.preventDefault();}" type="number">
Sample-2 : (Have tried this to solve issue in numeric keypad but doesnt work)
<input (keydown)="if(event.key=='.' || event.keyCode == 229 ||event.key===null ||event.key=='Unindentified'){event.preventDefaul();}" type="number">
Any help?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|