Do checkbox inputs only post data if they're checked?

后端 未结 12 758
盖世英雄少女心
盖世英雄少女心 2020-11-22 08:04

Is it standard behaviour for browsers to only send the checkbox input value data if it is checked upon form submission?

And if no value data is supplied, is the defa

12条回答
  •  不思量自难忘°
    2020-11-22 08:50

    From HTML 4 spec, which should be consistent across almost all browsers:

    http://www.w3.org/TR/html401/interact/forms.html#checkbox

    Checkboxes (and radio buttons) are on/off switches that may be toggled by the user. A switch is "on" when the control element's checked attribute is set. When a form is submitted, only "on" checkbox controls can become successful.

    Successful is defined as follows:

    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.

提交回复
热议问题