html - 输入标签中的这个模式属性指定密码长度不起作用?
问题描述
模式属性不起作用,我在下面包含了代码。它正在打印消息,但是当我输入 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,几乎所有浏览器都支持它。
推荐阅读
- java - 处理批处理记录后如何提交kafka offset
- c++ - 如何正确使用 LibIGL 的 AABB.signed_distance() 函数?
- oracle - 如何在从多个表中获取的查询中使用表中的行作为结果的列?
- javascript - 如何配置 Webpack 4 以实现热重载 html 代码?
- c# - List.Foreach 在 Using 块中使用一次性项目
- c# - 对联结表的引用抛出 ArgumentNullException 'Value cannot be null'
- reactjs - 如何在 Gatsby v2 中导入图像?
- ocaml - OCaml 阶数为 0
- netsuite - 将日期过滤器添加到脚本搜索(SuiteScript 1.0)的正确方法是什么?
- javascript - 如何将一个三维数组分成三个 for in 循环?