![]() |
VOOZH | about |
The task is to handle an input field if the number entered by the user in the input exceeds some limit using angularJS. We define a limitTo directive and use it on an HTML input element. This directive is used for all the handling of overflowing limits. The directive calls a function on the keypress event where we can check for the limits.
Example 1: This example sets the value of user input to 0 if its limit exceeds 100.
Output: As soon as the user exceeds 100, the value is set back to 0.
Example 2: In this example, we change the text based on the input limit. If the value of the input is less than 0 then it goes to 0. If its value is greater than 100 then it goes to 100 otherwise it stays as it is.
Output: