首页 > 解决方案 > 如何在 HTML 中编写输入电话号码的模式属性?

问题描述

问题是:

我的代码是

<input type="tel" name="telephone" id="telephone" required placeholder="Pattern: 234-567-8910" pattern="">

在属性模式中写什么?

标签: htmlwebinputattributes

解决方案


输入中的模式将采用正则表达式。您的要求是获得符合要求的正则表达式 [模式:234-567-8910]。

正则表达式将是

 pattern="[0-9]{3}-[0-9]{3}-[0-9]{4}"

推荐阅读