HTML form fields that, when not selected, do not even send a field name upon submit

Checkboxes and radio buttons that have not been checked and multiple select lists that have no selection submit nothing upon submission of the form. It’s as though they aren’t even there.

At first, this may seem obvious (Well, yeah, you didn’t select them, dummy!), except that it runs counter to every other form field.

If you have a text field named “surname” and you submit the form with no value in “surname”, the submission still includes the variable name “surname” but it has no corresponding value. You have the key with a null value.

It’s the same with textareas, any other type of input element, and select lists (where you are limited to a single selection). Even named buttons submit their values.

So, the stealthy cuplrits:

  • input type=”radio”
  • input type=”checkbox”
  • select multiple=”multiple”

Adam and I learned this in the midst of discussing and testing code this evening.

Leave a Reply

Your email address will not be published. Required fields are marked *