Alert if ANY radio options are not checked

forms, javascript, jquery, radio-button

Solution

You have 3 radio groups, so there will be 3 checked inputs and 6 unchecked inputs, I suggest:

if ( $("input[type=radio]:checked").length < 3 ) {
    alert('Please answer all of the questions');
}

Problem

I have a form with 3 questions that have 3 radio options each. I want the form to send an alert if ANY of the questions are left blank. This code sends an alert only if ALL of the questions are left blank: ``` if (!$("input").is(':checked')) { alert("You left one blank!"); } ``` So, for example, if I have only one question answered, I want the alert to send. Instead, it continues on with the code.

Original source