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.