Html模式属性匹配或允许空白

时间:2014-11-14 17:25:54

标签: html regex html-form

我在html中有两个输入字段; phone_number和alt_phone_number。我希望alt_phone_number具有与phone_number相同的模式,并且附加选项为空白。有什么建议吗?

<input id="phone_number" maxlength="10" name="phone_number" pattern="[0-9]{7}|[0-9]{10}" placeholder="Phone Number" required="required" size="10" type="tel" />

<input id="alt_phone_number" maxlength="10" name="alt_phone_number" pattern="[0-9]{7}|[0-9]{10}" placeholder="Phone Number" required="required" size="10" type="tel" />

1 个答案:

答案 0 :(得分:1)

从alt_phone_number中删除“required”属性。

<input id="alt_phone_number" maxlength="10" name="alt_phone_number" pattern="[0-9]{7}|[0-9]{10}" placeholder="Phone Number"size="10" type="tel" />