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.
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.
Yes, you can have a valid input without a form.
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.
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).
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
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