Min and max value of input in angular4 application

后端 未结 9 1147
温柔的废话
温柔的废话 2020-12-08 13:01

I have an angular4 application with a form. In this one I have an input to enter a percentage. So, I want to block the input with value between 0 and 100. I tried to add

9条回答
  •  醉酒成梦
    2020-12-08 13:57

    Actually when you use type="number" your input control populate with up/down arrow to increment/decrement numeric value, so when you update textbox value with those button it will not pass limit of 100, but when you manually give input like 120/130 and so on, it will not validate for max limit, so you have to validate it by code.

    You can disable manual input OR you have to write some code on valueChange/textChange/key* event.

提交回复
热议问题