Input type=number validation is not working correctly in angular

I want input type=number to accept decimal numbers between 0.1 and 0.9 (only one decimal number after dot, for example: 0.11 is not allowed), and also number 1.
I'm trying to restrict that from a directive. It seems the directive works but then I press the submit button a value of the form control is incorrect.
For example, if I type 0.11, 0.1 is shown in the input but form control has value of 0.11.
If I type a number from 1 to 9, input is empty but form control has value of that number.
Here is a stackblitz link: https://stackblitz.com/edit/angular-ivy-xa5g8v?file=src%2Fapp%2Fapp.component.ts



Read more here: https://stackoverflow.com/questions/64947203/input-type-number-validation-is-not-working-correctly-in-angular

Content Attribution

This content was originally published by Sht Prod at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: