Input Password pattern attribute

Definition and Usage

pattern attribute sets or returns the value of the pattern attribute of the password field.

The HTML pattern attribute specifies a regular expression to check the value of the password field.

Tip:Please use global HTML title attribute or DOM title Use properties to describe the pattern to help users.

See also:

JavaScript Tutorial:Regular Expression

JavaScript Reference Manual:RegExp Object

HTML Reference Manual: HTML pattern attribute of <input>

Example

Get the pattern attribute value of the password field:

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

Try it yourself

Syntax

Return the pattern attribute:

passwordObject.pattern

Set the pattern attribute:

passwordObject.pattern = regexp

Attribute Value

Value Description
regexp Specifies the regular expression to check the value of the password field.

Technical Details

Return Value: A string value representing a regular expression.

Browser Support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support 10.0 Support Support Support