It seems the minlength
attribute for an field doesn\'t work.
Is there any other attribute in HTML5 with the help of which I
minlength
attribute is now widely supported in most of the browsers.
But, as with other HTML5 features, IE11 is missing from this panorama. So, if you have a wide IE11 user base, consider using the pattern
HTML5 attribute that is supported almost across the board in most browsers (including IE11).
To have a nice and uniform implementation and maybe extensible or dynamic (based on the framework that generate your HTML), I would vote for the pattern
attribute:
There is still a small usability catch when using pattern
. The user will see a non-intuitive (very generic) error/warning message when using pattern
. See this jsfiddle or below:
In each form type 1 character and press submit
For example, in Chrome (but similar in most browsers), you will get the following error messages:
Please lengthen this text to 2 characters or more (you are currently using 1 character)
by using minlength
and
Please match the format requested
by using pattern
.