RESTRICT INPUT VALUES USING PATTERN MATCHING
You can use the pattern matching attribute, new in HTML5, to restrict input fields to values that follow a custom formatting pattern you define. This is useful if you need to ensure that the user submits correctly formatted values; otherwise display a message to the user and stops the form submission process.
<input type='text' ... pattern='pattern' title='title'>
The type attribute can be a text-based input type, such as text, number, telephone, and search. The pattern variable represents a regular expression syntax that defines the format of acceptable values that can be submitted by the user. A regular expression allows you to restrict values to very specific, finely tuned formats. Because different ...
Get HTML5: Your visual blueprint™ for designing rich web pages and applications now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.