Handling HTML Checkboxes with a default value
I’ve used this tip myself previously, it’s useful if you want to set a default for a checkbox, such as false:
Add an input of type “hidden”, and set the value to false before you declare the one with your true value, so for example, you could do this:
<input type="hidden" name="agree_to_terms" value="false">
<input type="checkbox" name="agree_to_terms" value="true">
There was this blog post that reminded me of this.
Found this useful? Everything here is free and stays that way. If it saved you an afternoon, you can buy me a coffee.