An example is given using j Query at this link : I notice that sometimes in chrome when autofill is on and the fields are field by the autofill browser build in method, it bypass the minlength validation rules, so in this case you will have to disable autofill by the following attribute: autocomplete="off" If the value of the "type" is one of them: text, email, search, password, tel, or url (warning:not include number | no browser support "tel" now - 2017.10) use minlength(/ maxlength) attribute , it specifies the minimum number of characters. 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 //prefix="prefix_text" //if the user change the prefix, restore the input with the prefix: if(Element By Id('my Input').value.substring(0,prefix.length).locale Compare(prefix)) Element By Id('my Input').value = prefix; are not available unfortunately.
It should work across more browsers and devices making it more usable and accessible.
Hacks for specific browsers (I’m looking at you Internet Explorer) also won’t validate, though it’s unlikely you’ll find a developer who’s never written a coding hack.
Ultimately validation is simply a tool to help you code better.