Can this replace minlength and maxlength?

Considering the usage of pattern to set a minimum and maximum number of characters for the input field, why does it not work when I replace the “minlength=3 maxlength=15” (attributes in the username input) for “pattern={3,15}” ?

That is an incomplete attribute. Being as this is HTML, there might not be any indication of error apart from it just not working.

We need both pieces of the regex pattern so there is a class to match to.

pattern="[a-zA-Z0-9]{3,15}"

http://html5pattern.com/


The best place to start is at the beginning, as forms go.

<form>

Study this page closely and thoroughly, then begin to go down the left side menu, element by element. Rinse and repeat.

A course will introduce seemingly arbitrary elements and attributes that appear disjunct. Documentation pages help to form a collection of related elements/attributes. Reach for the docs on every new element and begin to read them with ease. You’ll see.


the pattern attribute

2 Likes