0

I have a form and it contains multiple input fields. What if i don't provide an id or name to each and every field. will that field be submitted with some default name or won't be submitted at all.

This is just a query. No code involved. Thanks

2 Answers 2

1

Form controls without names cannot be successful controls and will not be submitted.

The value of a control without a name will not be included in the submitted form data.

See HTML 4:

A successful control is "valid" for submission. Every successful control has its control name paired with its current value as part of the submitted form data set. A successful control must be defined within a FORM element and must have a control name.

or HTML 5:

If any of the following conditions are met, then skip these substeps for this element … The field element is not an input element whose type attribute is in the Image Button state, and either the field element does not have a name attribute specified, or its name attribute's value is the empty string.


The id is irrelevant to the success of a control. Only the name matters there.

The id is still important to include as it is the best way to associate a <label> element with a control (and has other uses via JS and CSS).

Sign up to request clarification or add additional context in comments.

Comments

0

The form will still get submitted but you won't be able to get the 'post' values when the form has been submitted.

2 Comments

you mean the field with no value is lost ultimately?
Yes we didn't get the values.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.