Skip to content Skip to sidebar Skip to footer

Multiple Forms With Input Fields With The Same Name Attribute? Good Or Bad?

Is it an acceptable practice to have multiple HTML forms on a page with input fields that share the same name attribute? For example, the page contains a listing of all players and

Solution 1:

Agree with above answer. Name is totally ok, and will be passed as response parameter of your form. Different story would be if your input elements would have same id's as well - some browsers might have problems traversing dom of your document.

Again, think of bunch of radio buttons, where users can select gender etc. They must have same name (but different id's)...

Solution 2:

Yes it is valid, I do it all the time.

Solution 3:

yes that's perfectly fine.. in fact i personally feel that its really a good practice to do so as it turns relatively pretty handy for developers to work with relatively less names as compared to bunch of them.. moreover when elements are on different forms it dose not cause name space collision in any way since to identify elements in js by name we use both form name as well as input field name so it dose not cause any issues...

Post a Comment for "Multiple Forms With Input Fields With The Same Name Attribute? Good Or Bad?"