Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does form data still transfer if the input tag has no name?

For efficiency purposes I am wondering if a file or text in a textarea still gets transferred to the server if you omit the name attribute or set it to null. eg

<input type="file" id="file" name=""> <textarea id="text" name=""> 

I notice that the data is not available at the server if you do this.

like image 290
Jamie Kitson Avatar asked Sep 22 '12 12:09

Jamie Kitson


People also ask

Does a form input need a name?

name is required, and id is not that important. However, id is used to associate labels to common form input fields like radio button, textboxes, etc. The name attribute is not required.

Do input tags need to be in a form?

Yes, you can have a valid input without a form.

Is name attribute necessary in input tag?

Name is not a required attribute. A small quote from the HTML spec: The name content attribute gives the name of the form control, as used in form submission and in the form element's elements object. If the attribute is specified, its value must not be the empty string.

Is form tag necessary?

Form tags are still necessary if you want to be able to submit the form without AJAX (which may be useful in the early stages of development).


1 Answers

The W3C specification, if I understand it correctly, mandates that every form input element has a name attribute specified. Otherwise that element will not be processed. Source

like image 83
Petter Avatar answered Oct 03 '22 15:10

Petter