Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do input field NAMES have to be unique across forms?

Tags:

forms

xhtml

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

like image 301
sdfor Avatar asked Sep 01 '09 17:09

sdfor


People also ask

Should input names be unique?

Yes, it validates (with surrounding body, doctype, etc added). No warnings re the duplicate names.

Can two forms have the same name?

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

Does name attribute have to be unique HTML?

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.

Is it important to name an input field?

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.

What is input fields?

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.


2 Answers

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>
like image 185
Greg Avatar answered Oct 26 '22 17:10

Greg


No they do not have to be unique across forms, but should be unique within forms except for radio buttons.

like image 26
Nosrama Avatar answered Oct 26 '22 16:10

Nosrama