Frank
Frank

Reputation: 708

HTML 5 require either input fields

Lets say I have two input fields

<input id='intput1' type='text' />
<input id='intput2' type='text' />

Can I use the html 5 attribute required to specify that either input1 or input2 is required

Upvotes: 5

Views: 1637

Answers (2)

Bjoern
Bjoern

Reputation: 16304

HTML5 adds a new attribute, required. See here for details.

This doesn't solve your problem because it is just defined for one specific field and doesn't check cross-field.

<input id='intput1' type='text' required='required' />
<input id='intput2' type='text' required='required' />

If you want to have a more flexible way of checking this, I advise adding some JScript for this.

Upvotes: 0

Matthew Flaschen
Matthew Flaschen

Reputation: 284806

Not as currently drafted:

The required attribute is a boolean attribute. When specified, the element is required.

Upvotes: 1

Related Questions