Angular- How to prevent text in input from showing if input is invalid

aspiringsomeone

I have an input text tag with [(ngModel)]=some_var . When the user inputs something that isn't a number or decimal, I want it to not show in the input box when typing. For example, if I type h in the text box I don't want to see h as I type it (if that makes sense).

I'm not sure which event to use.

Misha Mashina

If you only want numbers and dot as a decimal separator, you can just use:

<input type="number" (...) >

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to test for error condition from invalid input

How do I prevent AngularJS from unbinding a form input's value from its model when it's invalid?

How to prevent javascript from changing input value

How to prevent a user from removing the first three characters in a text input?

how to prevent "post accent" in input text

Prevent text from shifting in an input box

IE 10, 11. How to prevent the triggering of input events on focus from text input with placeholder?

Showing Invalid date in input field

How to save text from input to variable in angular?

How to prevent Vue input from setting value?

How to prevent an input from being disabled?

How to prevent input from displaying in address bar

How to prevent ReactSelect from clearing the input?

How to prevent user from typing numbers in input?

Is there a way to prevent a JFormattedTextField from automatically erasing invalid input?

Prevent an input from submitting

How to prevent reading input from text field if text field is disabled

Prevent space in input from both text input and copy and paste

Prevent text from wrapping around input

How to prevent <input> from stretching table cell?

How to prevent Opencart From stripping an input?

Prevent batch script from terminating upon invalid character input

How to check input in PreferenceActivity and prevent storing of invalid values?

How to prevent my app from crashing when there is no input or if input is invalid

How to prevent or remove foreground text input from background Java process?

How to prevent user from copy-pasting text with invalid characters into input text field immediately on copy-paste action?

How to check for text for invalid input

How to prevent icon position from changing in input when invalid feedback occur?

Prevent Stripe confirmPayment from redirecting when custom input field is invalid