Do input field NAMES have to be unique across forms?
I would imagine that it's ok since the reference to each input field is qualified by the form name.
document.form1.inp1.value document.form2.inp1.value
Am I right? Will it work in all browsers?
thanks
Yes, it validates (with surrounding body, doctype, etc added). No warnings re the duplicate names.
Only the name must be unique inside the form itself. See the docs: "The value must not be the empty string, and the value must be unique amongst the form elements in the forms collection that it is in, if any."
The name attribute is not unique. For instance, it is used to group radio buttons. It represents the value of a particular form property. id s must be unique.
Never omit the nameThe name attribute is probably the most important attribute of the <input> element. It isn't strictly required for validation, but you should never omit it. When a form is submitted to the server, the data from the form is included in an HTTP request.
Input fields are an essential user interface design element, providing users with the means to enter non-standardized responses. They are used in many different situations, but most people will have come across them when entering personal details and delivery addresses on e-commerce web forms or sending online queries.
No, they don't have to be unique across forms or within forms. The most common use of repeating them is radios:
<form>
<input type="radio" name="my_radio" value="1">
<input type="radio" name="my_radio" value="2">
<input type="radio" name="my_radio" value="3">
</form>
No they do not have to be unique across forms, but should be unique within forms except for radio buttons.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With