html - 如何在 HTML 中编写输入电话号码的模式属性?
问题描述
问题是:
- 电话输入字段类型应为“电话”,
- 占位符文本应该是
Pattern: 234-567-8910
- 限制输入的模式,它应该是一个必填(
required
)字段 - 模式应该是类型
[ Pattern: 234-567-8910]
。 - 元素名称应为:
telephone
.
我的代码是
<input type="tel" name="telephone" id="telephone" required placeholder="Pattern: 234-567-8910" pattern="">
在属性模式中写什么?
解决方案
输入中的模式将采用正则表达式。您的要求是获得符合要求的正则表达式 [模式:234-567-8910]。
正则表达式将是
pattern="[0-9]{3}-[0-9]{3}-[0-9]{4}"
推荐阅读
- neo4j - 在 grapheneDB 上正确配置图形数据科学插件
- javers - 比较没有id的javers中的实体
- javascript - Axios / JWT 发布 401(仅限 Mac OS 和 iOS)“rest_forbidden”
- c# - C# Unity,函数之外的命名参数语法?
- r - 具有自定义成本函数的插入符号模型
- php - 按顺序获取 id_cart_rules prestashop
- excel - HeapFree 崩溃了
- javascript - 在 AJAX 调用中更改 DOM 属性不起作用
- php - main():如果 ($stmt->num_rows > 0),则无法在第 31 行获取 mysqli_stmt
- c - 我可以在一个进程中拥有多个 POSIX FIFO 吗?