模式属性不起作用,我已包含以下代码。它正在打印消息,但是当我输入 6 或 7 或 8 个字符时,它不接受。
<input type="password" pattern=".{5,12}" name="password" id="password" required title="Password must be 5 to 12 characters"/>
最佳答案
它适用于表单提交事件。查看文档以了解其工作原理:https://www.w3schools.com/tags/att_input_pattern.asp
仅进行测试,请尝试单击下面代码段中的提交按钮。
<form>
<label>Password must be 5 to 12 characters:
<input type="password" pattern=".{5,12}" name="password" id="password" required title="Password must be 5 to 12 characters"/>
</label>
<button type="submit">Submit</button>
<form>
根据https://caniuse.com/#feat=input-pattern几乎所有浏览器都支持它。
关于html - 输入标记中用于指定密码长度的模式属性不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55389632/