pattern

Jump to: navigation, search

pattern

This page has been flagged with the following issues:

High-level issues:


W3C Candidate Recommendation

Summary

The pattern attribute specifies a regular expression that the <input> element's value is checked against.


Applies to HTMLInputElement

Examples

HTML

Numeric field: <input type="text" name="numericField" pattern="[0-9]*" />
Country code: <input type="text" name="country_code" pattern="[A-Za-z]{3}" title="Three letter country code">

Notes

Remarks

Several generic messages are displayed for a variety of validation errors. If you use a title attribute on an input element, it will both be shown as alt text for the field, as well as be appended to the generic error message. The following example shows a ZIP code number format.

Syntax

Standards information

Compatibility

Desktop

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic Support Supported (when?)
?
10
?
?

Mobile

Feature Android BlackBerry Chrome for mobile Firefox Mobile (Gecko) IE Mobile Opera Mobile Opera Mini Safari Mobile
Basic Support ?
?
?
?
10
?
?
?

See also

Related pages (MSDN)

Attribution

This article contains content originally from external sources.

Portions of this content come from the Microsoft Developer Network: [Windows Internet Explorer API reference Article]