0

I am building an application with angularJS, we have to give max length validation in it.

so we should use ng-maxlength or html maxlength attribute ?

what difference will it make?

Thanks.

Dreamweaver
  • 1,328
  • 11
  • 21

2 Answers2

2
  • If you like to strict length of an input field use maxlength.
  • If you like to validate the field value on its length use ng-maxlength. If a user inputs more than ng-maxlength attribute value then ng-invalid-maxlength class will be set to the field.
Alexander Elgin
  • 6,796
  • 4
  • 40
  • 50
1

The difference is that the standard approach(html) doesn't allow entering more than max, while Angular's(angular JS) approach just generates a validation error.

Chirag Patel
  • 373
  • 5
  • 20