If you add the autocomplete="off" attribute to the element it won't set the previous state after refresh..
In the case of a "checkbox", you have to actually modify the <input> to include the keyword "checked". Similarly for "options" and "text". For "text" you fill in the "value=" after suitably escaping the text (using htmlentities() ).
When rendering a page with a checkbox you want selected or checked by default you need to include the 'checked' attribute. There is no required value for the checked attribute. However, per the checkbox specification only an empty value or 'checked' are valid.
The checked attribute is a boolean attribute. When present, it specifies that an <input> element should be pre-selected (checked) when the page loads. The checked attribute can be used with <input type="checkbox"> and <input type="radio"> . The checked attribute can also be set after the page load, with a JavaScript.
Add autocomplete="off"
into the form element on the page. The downside is that this isn't valid XHTML, but it fixes the issue without any convoluted javascript.
Yes, I believe it is caching. I see this behaviour on Firefox for example (not Safari, for what that's worth :) ).
you can reload the page and bypass the cache (on Firefox) using CTRL-SHIFT-R and you'll see the check value doesn't carry (a normal CTRL-R will grab the info from the cache however)
edit: I was able to disable this server side on Firefox, setting a cache control header:
Cache-Control: no-store
this seems to disable the "remember form values" feature of Firefox
set autocomplete="off" with js is also working well.
for example using jquery:
$(":checkbox").attr("autocomplete", "off");
This is an old question but still an active issue for firefox. None of the responses i tried solved it, but what did solve it for me was simply this:
document.getElementById('formId').reset();
This simply resets the form to the default options every time the page loads. Not ideal since you lose granular control, but its the only thing that solved this for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With