{ "id": "api/forms/MaxLengthValidator", "title": "MaxLengthValidator", "contents": "\n\n
\n
\n
\n \n API > @angular/forms\n
\n \n
\n \n
\n

MaxLengthValidatorlink

\n \n \n \n \n \n
\n \n \n\n
\n \n
\n

A directive that adds max length validation to controls marked with the\nmaxlength attribute. The directive is provided with the NG_VALIDATORS multi-provider list.

\n\n \n
\n \n \n \n \n
\n

See alsolink

\n \n
\n\n\n

NgModuleslink

\n\n\n\n \n
\n

Selectorslink

\n \n \n \n
\n\n\n\n \n\n
\n

Propertieslink

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
PropertyDescription
\n \n @Input()
maxlength: string | number
\n
\n \n

Tracks changes to the maximum length bound to this directive.

\n\n \n
\n
\n\n\n\n \n\n\n \n
\n

Descriptionlink

\n \n

Adding a maximum length validatorlink

\n

The following example shows how to add a maximum length validator to an input attached to an\nngModel binding.

\n\n<input name=\"firstName\" ngModel maxlength=\"25\">\n\n\n
\n \n\n \n\n \n\n \n\n \n \n \n\n
\n
\n\n\n" }