我想要表单的邮政编码部分,所以只允许 5 个数字,使用 html 模式拒绝任何不以 46,52,53,54,60,61,62 开头的内容
Try the below pattern (starts with one of the specified numbers and then allow 3 digits):
^(46|52|53|54|60|61|62)([0-9]{3})$
Here is the running HTML sample. You may use this pattern in Javascript as well if you want to perform the validation yourself:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Prescriptions</title> </head> <body> <form action="#"> Country code: <input type="text" name="country_code" pattern="^(46|52|53|54|60|61|62)([0-9]{3})$" title="Enter five digit number starting with specific numbers"> <input type="submit"> </form> </body>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.