How to Deselect a Radio Button

Ever filled out an online form, only to accidentally check a radio button, with no way to undo it? Radio buttons are typically used for multiple choice questions, where you can only select one answer.

The problem with radio buttons is that once you select it, you can’t deselect or uncheck it. The only way to deselect it is to choose a different choice. But what if you don’t want to select any choice or there’s only one button to select?

Radio Button

How do I leave this question blank if I already answered it?

Properly designed forms would provide a button to clear the radio buttons. However, not all forms provide this functionality.

Fortunately, a bit of JavaScript can help. Simply clear your address bar and paste the following in exactly as it is (double click to select all). Then hit Enter/Return.

This will clear every single radio button on the page. Some browsers, like Google Chrome, may automatically remove javascript: from the beginning of this when copied into the URL bar. Be sure to manually type it back in.

javascript:(function(){var%20findInputs=document.getElementsByTagName(%27input%27);for(var%20i=0;i<findInputs.length;i++){if(findInputs[i].getAttribute(%27type%27)===%27radio%27)findInputs[i].checked=false;}})()

You should notice all radio buttons on the page cleared.

This can also be saved as a bookmarklet. Simply drag this link to your bookmarks: Clear Radio buttons

Click the bookmarklet whenever you need to clear all the radio buttons on a page.

/*
Clear Radio buttons
Brian Yang
TechAirlines.com
*/

function clearRadios() {
	var findInputs = document.getElementsByTagName('input');
	for (var i = 0; i < findInputs.length; i++) {
		if (findInputs[i].getAttribute('type') === 'radio')findInputs[i].checked=false;
	}
}

Did this script work for you? Have another solution for this problem? Share with us in the comments.

Liked this article? Share it with your friends.

By
Brian is the co-founder of TechAirlines. He is a developer currently focusing on mobile and web development. He is currently a sophomore at Stony Brook University, majoring in Computer Science.

  • T

    UGHHHH THANK YOU

  • w

    AWESOME! THANK YOU SO MUCH!

  • hassan

    Great helped me with a form I messed up…