Common Bootstrap 5 form templates pattern Attribute Summary:
- Validation Text Box: Checks whether the value in the validation text box matches the specified regular expression. For example,
pattern="[a-zA-Z]{3,}$"This indicates that the verification string must contain at least three letters, and the last character cannot be a digit or a space. - Password Verification Field: Checks whether the value in the Password Verification Field matches the specified regular expression. For example,
pattern="(?=.*[a-zA-Z])(?=.*\\d)(?=.*[!@#$%^&*()_+])[a-zA-Z\\d!@#$%^&*()_+]{8,}$"The password must contain at least one letter, one digit, and one special character, and must be at least 8 characters long. - Email Validation Field: Checks whether the value in the Email Validation Field matches the specified regular expression. For example,
pattern="^([a-zA-Z0-9_\.-]+)@([\da-zA-Z\.-]+)\.([a-zA-Z\.]{2,6})$"The email address must consist of letters, digits, dots, underscores, or dashes; however, a dot cannot appear at the beginning or the end of the email address. - Mobile phone number verification field: Verify whether the value in the mobile phone number verification field matches the specified regular expression. For example,
pattern="^1[3|4|5|6|7|8|9][0-9]{9}$"The mobile phone number must start with a digit, followed by one of the digits 3, 4, 5, 6, 7, 8, or 9; the number must be 11 digits long. - Verify URL Field: Checks whether the value in the Verify URL Field matches the specified regular expression. For example,
pattern="^(https?|ftp|ssh)://[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$"The URL must use the HTTPS protocol; it must start with https://, http://, or ftp://; and the URL length must not exceed 2000 characters. - Date format validation: Checks whether the date format matches the specified regular expression. For example,
pattern="^([0-9]{2}-[0-9]{2}-[0-9]{4})$"The date must be entered in the year–month–day format. - Verify time format: Check whether the time format matches the specified regular expression. For example,
pattern="^([0-9]{2}-[0-9]{2}-[0-9]{4} [0-9]{2}:[0-9]{2}:[0-9]{2}Z)$"The time must be entered in the format Year-Month-Day H:M:S.
In addition to the above-mentioned uses,pattern The attribute can also be used in other ways, depending on the specific application scenario.