Johan
Johan

Reputation: 35194

Keep single radio button unchecked on page load

I have a radio button in my html:

<!DOCTYPE HTML>
<html lang="en-US">
<head>
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
    <input type="radio" name="r"/>
</body>
</html>

If I check it, and reload the page (Firefox 20.0.1) it will stay checked. But if I clear the cache (ctrl+f5) the button gets unchecked again.

Is there any way to make it consistent so that it always unchecks itself when the page is refreshed? Or do I need to involve javascript? I've tried with and without the name property.

PS. I wasn't able to make a fiddle. Try it on a local file in order to reproduce it.

Upvotes: 1

Views: 5751

Answers (1)

Kasyx
Kasyx

Reputation: 3200

You can set autocomplete="off":

<input type="radio" name="r" autocomplete="off" />

Please check this documentations:

Mozilla Dev

W3C

And working example: http://fiddle.jshell.net/2fAuY/2/show/ (thank you @ValarDohaeris for fiddle)

Upvotes: 7

Related Questions