I am using HTML5 \'pattern\' attribute with \'required\' for validation of input boxes. HTML5\'s required attribute works but it can accept spaces and tabs which is not good
I managed a silly hack that does what you asked:
There must be 6 non-space characters for this to pass. so "asdfgh", " abc def " will work, but "abc de" fails.
It DOES NOT work for your comment about "there's a space after Anthony" but as Anthony contains 6 characters, then it's fine? If not, can you clarify further in the question.
To explain how it works:
\S
followed by "none-or-more space characters" \s*
(pattern){6,}
i.e. (\S\s*){6,}
\s*
If you want to limit the characters allowed to Alpha only, change the \S
to [A-Za-z]
.
Yes, it's a hack IMO as it will be hell to parse internally on long strings. But does the job. You might want to mix with maxlength
to limit that as well?