Closed esmin closed 5 years ago
The checkboxUncheckedValue
option was defined because by default HTML form checkboxes don't have a way to specify the unchecked value. They work by sending the value from the value
property (or using "on" by default, although this depends on the browser), or sending nothing if unchecked.
Yes, it would be nice to have an option to specify the default value for checkboxes with no value
property, but it is very easy to simply specify a value
property, and it results in more idiomatic HTML. It is by design this library implements as few options as possible to keep it simple. There needs to be a strong reason to implement that option.
Play with this online tryit editor to see how the default jQuery.serializeArray
works with checkboxes (serializeJSON plugin is not being used):
https://www.w3schools.com/code/tryit.asp?filename=G8QAARDD4PDU
See this comment for more info about how to serialize checkbox values: https://github.com/marioizquierdo/jquery.serializeJSON/issues/70#issuecomment-282531642
Not having value defined for checkbox sends "on" text.
Already having checkboxUncheckedValue option, this would be nice helpful addition