[英]html form regex pattern validation
I have been searching google for some time but cannot get my html pattern validation to work correctly :(我一直在搜索谷歌一段时间,但无法让我的 html 模式验证正常工作:(
I have 2 phone fields in my form - home and mobile - which I am trying to use pattern=""
to validate.我的表单中有 2 个电话字段 - home 和 mobile - 我正在尝试使用
pattern=""
进行验证。 However the regex is difficult and I don't really understand how this works.然而,正则表达式很困难,我真的不明白这是如何工作的。
The requirements are as follows:要求如下:
A mobile phone number number should:手机号码应该:
Home phone numbers must only begin with 01 or 02 or 03.家庭电话号码只能以 01 或 02 或 03 开头。
Mobile phones: 07[12345789]\\d{7,8}
手机:
07[12345789]\\d{7,8}
Home phones: (01|02|03)\\d+
家庭电话:
(01|02|03)\\d+
If there are the same length restrictions for home phones, then instead of \\d+
you have to use \\d{8,9}
如果家用电话有相同的长度限制,那么您必须使用
\\d{8,9}
而不是\\d+
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.