为什么我的 HTML5 表单验证模式 (/^\S{6,}$/) 触发不正确?
我有一个如下所示的表单输入:
<input name="password" type="password" required pattern="/^\S{6,}$/"/>
输入的要求是:至少 6 个字符,并且没有空格或不规则字符。问题是,即使满足这些要求,也会触发“无效”消息。这是为什么? /^\S{6,}$/ 有问题吗?
I have a form input that looks like this:
<input name="password" type="password" required pattern="/^\S{6,}$/"/>
The requirements for the input is: at least 6 characters and no white space or irregular characters. The problem is that even when those requirements are satisfied, the "invalid" message is triggered. Why is that? Is there something wrong with /^\S{6,}$/ ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
pattern
属性中不需要前后斜杠。删除它们,你应该没问题。The slashes before and after are not needed in the
pattern
attribute. Remove them and you should be fine.我认为您需要删除前导和尾随
/
字符。I think you need to remove the leading and trailing
/
characters.