javascriptangularformstypescriptautocorrect

How do I set 'selective-input' to a form field in Angular?


I have a form input field in angular that is to be filled with a number.

How can I set it up in a way that when you try to add any other character that is not a number, nothing happens. How can my form work as if only integer keys on the keyboard are working? For example if my form has 100 and I try to input a character like the plus sign nothing happens?

here is the code for my form.


Solution

  • If you want your input to be only number you can specify that with type property, for example:

    <input type="number" />
    

    and it will accept only integers.