Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
AngularJS – ngMaxlength Directive
The ngMaxlength Directive in AngularJS adds the maxlength validator to the ngModel. This directive is mostly used to control the text-based inputs but can also be applied for controlling the custom text-based controls.
This validator sets the maxlength error key if the value ngModel.$viewValue is longer than the integer value obtained by evaluating the Angular JS expression defined in the ngMaxlength attribute value.
Syntax
..content..
Example − ngMaxlength Directive
Create a file "ngMaxlength.html" in your Angular project directory and copy-paste the following code snippet.
ngMaxlength Directive Welcome to Tutorials Point
AngularJS | ngMaxlength Directive
Output
To run the above code, just go to your file and run it as a normal HTML file.
Observe the output when the length of the entered text becomes greater than the maxlength, the input becomes invalid.
