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;
Syntax
Return pattern attribute:
passwordObject.pattern
Set pattern attribute:
passwordObject.pattern = regexp
属性值
值 | 描述 |
---|---|
regexp | 规定检查密码字段值的正则表达式。 |
技术细节
返回值: | 字符串值,表示正则表达式。 |
---|
浏览器支持
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
支持 | 10.0 | 支持 | 支持 | 支持 |