English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Dieser Artikel beschreibt die Verwendung des HTML-input-pattern-Attributs, zeigt Beispiele, wie man das HTML-input-pattern-Attribut verwendet, die Kompatibilität der Browser, die Syntaxdefinition und detaillierte Informationen zu seinen Attributswerten.
Ein HTML-Formular, bei dem die Eingabefelder nur drei Buchstaben enthalten können (keine Ziffern oder Sonderzeichen):
!DOCTYPE html> <html> <head> <title>HTML:<input> pattern Eigenschaft - Grund教程网(oldtoolbag.com)</title> <body> <form action="action_page.php"> Land/Landeskennung: <input type="text" name="country_code" pattern="[A-Za-z]{3" title="3ein Buchstabe des Landes/Landeskennung"> <input type="submit"> </form> </html>Testen Sie heraus ‹/›
IEFirefoxOperaChromeSafari
Internet Explorer 10, Firefox, Opera and Chrome support the pattern attribute.
Note:Safari or Internet Explorer 9 and earlier versions do not support the pattern attribute of the <input> tag.
The pattern attribute specifies a regular expression that checks the value of the <input> element when the form is submitted.
Note:pattern attribute is applicable to the following input types: text, search, url, tel, email and password.
Tip:Please use the global title Attribute to describe the pattern to help users.
Tip:You can learn more about it in our JavaScript tutorial. Regular Expressions knowledge.
The pattern attribute is an HTML5 New attributes added in
<input pattern="regexp">
Value | Description |
---|---|
regexp | Regular expressions are used to define the patterns for validating the values of the <input> elements. |