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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.