Input Search pattern Attribute
Definition and Usage
pattern
Attribute sets or returns the value of the pattern attribute of the search field.
The HTML pattern attribute specifies a regular expression used to check the value of the search field.
Tip:Please use global HTML title attribute or DOM title Use attributes to describe the pattern to help users.
See also:
JavaScript Tutorial:Expresiones regulares de JavaScript
JavaScript Reference Manual:JavaScript RegExp Object
HTML Reference Manual:Atributo pattern de <input> de HTML
Example
Get the pattern attribute value of the search field:
var x = document.getElementById("mySearch").pattern;
Syntax
Return the pattern attribute:
searchObject.pattern
Set the pattern attribute:
searchObject.pattern = regexp
attribute value
value | description |
---|---|
regexp | Define the regular expression for checking the value of the text field. |
Detalles técnicos
Valor de retorno: | Valor de cadena, que representa la expresión regular. |
---|
Compatibilidad del navegador
Los números en la tabla indican la versión del navegador que admite completamente la propiedad.
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Soportado | 10.0 | Soportado | No soportado | Soportado |