Christopher Brandt
Christopher Brandt

Reputation: 25

Html Pattern Attribute Match or Allow Blank

I have two input fields in html; phone_number and alt_phone_number. I want alt_phone_number to have the same pattern as phone_number with the additional option of it being blank. Any advice?

<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" />

Upvotes: 1

Views: 1445

Answers (1)

pdubs
pdubs

Reputation: 2848

Remove the "required" attribute from alt_phone_number.

<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" />

Upvotes: 2

Related Questions