I have a xhtml page with transitional doctype having a checkbox that I want to be unchecked after loading. No JavaScript! In Firefox 3.5 (for instance, there may be other browsers) user can check input, than reload page and get input checked. How can I overcome this behaviour?
-
7I'm pretty sure `autocomplete="off"` should work in your case I think. – JohnP Apr 29 '11 at 11:03
-
JohnP you should Answer instead of commenting. – Oleg Kubrakov Apr 29 '11 at 18:17
-
2In firefox, it is also common that if a checkbox input does not have a name, it is checked by default. – shasi kanth Aug 22 '13 at 11:03
-
Seems to be a duplicate of http://stackoverflow.com/questions/299811/why-does-the-checkbox-stay-checked-when-reloading-the-page – T. Junghans Sep 26 '13 at 13:43
-
shasi: Thanks for that comment; saved me. Couldn't figure out why my logic was backwards in Firefox. – Kalnode Sep 28 '18 at 17:48
5 Answers
Use
autocomplete="off"
Also have a look at Why does the checkbox stay checked when reloading the page?

- 1
- 1

- 11,385
- 7
- 52
- 75
You can't do much to change a document's state with HTML alone. All you can do is set checked="checked"
or not.
You need either JavaScript or a server side language to determine whether that attribute should be set or not.

- 479,566
- 201
- 878
- 984
-
JohnP made a comment that does for me best, but it should be mentioned that header "Cache-Control: no-cache" also helps. – Oleg Kubrakov Apr 29 '11 at 18:15
You can't, not without JavaScript. This is Firefox specific behaviour which would occur even if you could explicitly force an "unchecked" state (which you can't, because the absence of checked
already means that.)
The only non-Javascript way that I know of is to rename the form element on server-side on every request so FF has no chance of storing the value.

- 442,112
- 142
- 972
- 1,088
To explicitly set the checkbox to unchecked, the following worked for me:
<input type="checkbox" unchecked>

- 309
- 2
- 10
Try to put in your code this:
<p><label><input id="test" type="checkbox"></input>Test checkbox</label></p>
It will be unchecked when the page starts or refreshes.

- 724
- 2
- 9
- 25
-
-
According to [Mozilla's MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Input/checkbox#checked), Firefox persists checkbox status between page loads via autocomplete. – sondra.kinsey Feb 21 '19 at 16:03