O'Reilly logo

HTML5: Your visual blueprint™ for designing rich web pages and applications by Adam McDaniel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required