Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do all browsers ignore nameless input fields?

Is it guaranteed that a browser doesn't send an input element if it doesn't have the name attribute specified?

For example, can we assume that POSTing the form below won't send the credit card number?

<form action="/process" method="post">
  <input id="credit-card-number" type="text">
  <input type="submit" name="commit" value="Go">
</form>
like image 219
randomguy Avatar asked Oct 08 '12 15:10

randomguy


People also ask

Is it not important to name an input field?

Never omit the name The data is packaged as a series of name-value pairs. The name for each name-value pair is the name attribute of each input, and the value is the user-entered (or pre-specified) value. Without the name attribute, an <input> element cannot provide its value to the server on form submission.

Which field in the form prevent the data to been seen by other?

A hidden field lets web developers include data that cannot be seen or modified by users when a form is submitted.

Do input fields need to be in a form?

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


1 Answers

Is it guaranteed that a browser doesn't send an input element if it doesn't have the name attribute specified?

Yes (unless you muck about with JavaScript to change that).

The specification is quite clear that controls without names cannot be successful.

A successful control must be defined within a FORM element and must have a control name.

like image 93
Quentin Avatar answered Oct 04 '22 06:10

Quentin