VOOZH about

URL: https://www.geeksforgeeks.org/angular-js/angularjs-ng-minlength-directive/

⇱ AngularJS ng-minlength Directive - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

AngularJS ng-minlength Directive

Last Updated : 16 Aug, 2022

The ng-minlength Directive in AngularJS is used to set the minimum length for an input field i.e it adds the restriction for an input field. It is different from minlength attribute in HTML because the former prevents users from entering less than the specified limit whereas the later doesn't do that. It makes the form invalid if the entered input is less than the specified limit. 

Syntax:

<element ng-minlength="expression"> 
 content... 
</element> 

Parameter:

  • expression It specifies the number denoting the minimum limit below which the input is invalid. 

Example 1: This example uses the ng-minlength Directive to set the minimum length of the string. 

Output:

👁 Image
 

Example 2: In this example, we will render the warning message if the entered character is less than 5 in the input field with the help of the ng-minlength Directive.

Output:

👁 Image
 
Comment

Explore