Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

Is it valid markup and is it valid to the html/http spec? If I wanted to have

<form>
<input name="email" />
<input name="email" />
<input name="email" />
</form>

is that valid?

share|improve this question
    
By definition, radio buttons in the same group have the same name. –  w3d Feb 28 '11 at 9:58

1 Answer 1

up vote 6 down vote accepted

As stated on SO:

The browsers are OK with it. However, how the application library parses it may vary.

Programs are supposed to group identically named items together. While the HTML specification doesn't explicitly say this, it is implicitly stated in the documentation on checkboxes:

"Several checkboxes in a form may share the same control name. Thus, for example, checkboxes allow users to select several values for the same property."

On a side note, in PHP you can have form fields with the same name if you use PHP's arry syntax for the field name:

<form>
<input name="email[]" />
<input name="email[]" />
<input name="email[]" />
</form>

This will cause the browser to send over the form fields in a syntax that PHP will use to populate an array for these fields: $_REQUEST['email']. If you use PHP this is the preferred way to handle it.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.