Input Email pattern Property

Input Email 对象参考手册Input Email Object

Examples

Get the value of the pattern attribute of the email field:

var x = document.getElementById("myEmail").pattern;

xThe output result is:

[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,3}$

Try it yourself »


Definition and Usage

The pattern attribute is used to set or return the value of the pattern attribute of the email field.

The pattern attribute describes a regular expression that is used to validate the value of the email field.

Tip:Use the global HTMLtitleattribute or DOMtitleattribute to help the user describe the pattern.

Tip:You can learn aboutregular expressions 。

Tip:You can also check out ourJavaScript RegExp Reference。


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

Internet Explorer 10, Firefox, Opera, and Chrome support the pattern attribute.

Note:Internet Explorer 9 and earlier IE versions, and Safari do not support the pattern attribute.

Note:Internet Explorer 9 and earlier IE versions, and Safari do not support the <input type="email"> element.


Syntax

Return the pattern attribute:

emailObject.pattern

Set the pattern attribute:

emailObject.pattern=regexp

Attribute Values

Value Description
regexp Describes the regular expression used to validate the email field

Technical Details

Return Value: A string representing a regular expression


Related Pages

HTML Reference:HTML <input> pattern Attribute


Input Email 对象参考手册Input Email Object

Other extensions