To restrict user to enter only specific pattern of characters in HTML 5, we use pattern
attribute.
<input required pattern="[A-Za-z]{3}" title="3 alphabets characters only" />
In the above code snippet, we have pattern attribute value set as [A-Za-z]{3} that forces the user to only enter three alphabets character (not more and not less). No numeric characters will be allowed.
The pattern attribute value is basically a regular expression, to learn more about regular expression, visit this post.
Output
Views: 18533 | Post Order: 97