[英]HTML5 Validation issue
I'm trying to validate input using HTML5 pattern
tag.我正在尝试使用 HTML5
pattern
标记验证输入。 Have 3 separate input checks:有 3 个单独的输入检查:
[A-Ea-e]{1}
For example: A, B, e ... [A-Ea-e]{1}
例如:A、B、e ...[0-9]+,*[0-9]+
For example: 0,52356, 0677,67 ... [0-9]+,*[0-9]+
例如:0,52356, 0677,67 ...[A-Ea-e]{3}
for example: AbE, cDa [A-Ea-e]{3}
例如:AbE、cDa I want to add to all of this samples or * sign with 1 char limit
condition.我想添加到所有这些样本
or * sign with 1 char limit
条件。
For every check that listed above there might be 1 * sign which is also accepted.对于上面列出的每张支票,可能会有 1 个 * 符号也被接受。 But if there is * sign, adding more characters must end with invalid result.
但是如果有*号,增加更多的字符必须以无效结果结束。
I'm new to regex.我是正则表达式的新手。 Can not figure out.
想不通。
Any suggestions?有什么建议?
^([A-Ea-e]{1}|[0-9]+(,[0-9]+)*|[A-Ea-e]{3})\*?$
Valid:有效的:
A
AAA
1
1,2
1,2,3
A*
AAA*
1*
1,2*
1,2,3*
Invalid:无效的:
AA
AAAA
,1
1,
1,**
If you want them separate:如果你想让它们分开:
^[A-Ea-e]{1}\*?$
^[0-9]+(,[0-9]+)*\*?$
^[A-Ea-e]{3}\*?$
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.