jquery check if radio button is checked and then check if tickbox is checked

0 votes

Hi, I have a two part form which I have developed. One is for existing members and one is not.

On one of the forms I have a checkbox which will need to be checked before they can proceed, to determine that they are on the correct form. I will use the radio button which hides and unhides forms.

However when I try to get a handle on if the radio button is checked and then checking to see if the checkbox is checked I get nothing returned.

Can someone help me implement this? My JS is below or view my JSFIDDLE:

$(document).ready(function(){

    var check;   

    if($("input:radio[name=existingpartner]").is(":checked")){

        // Example 3 - With jQuery prop  
    $("#test-with-prop").on("click", function(){
        check = $("#mycheckbox").prop("checked");
        if(check) {
             alert("Checkbox is checked.");
        } else {
            alert("Checkbox is unchecked.");
        }
    }); 
});

Aug 1, 2022 in Web Development by gaurav
• 23,260 points
4,215 views

1 answer to this question.

0 votes

This is the best and the most recommended way when using jQuery:

if( $('#radio').is(':checked') ){
    alert("Radio Button Is checked!");
}
else{
    alert("Radio Button Is not checked :( ");
}
answered Aug 1, 2022 by rajatha
• 7,680 points

Related Questions In Web Development

0 votes
0 answers

How to check radio button is checked using JQuery?

I have two radio buttons in one ...READ MORE

Jun 29, 2022 in Web Development by gaurav
• 23,260 points
493 views
0 votes
0 answers

jQuery: Test if checkbox is NOT checked

I'm having trouble figuring this out. I ...READ MORE

Jun 29, 2022 in Web Development by gaurav
• 23,260 points
735 views
0 votes
0 answers

jQuery if checkbox is checked

I have a function below that I ...READ MORE

Jun 29, 2022 in Web Development by gaurav
• 23,260 points
487 views
0 votes
1 answer

What is the difference between JavaScript and jQuery?

JavaScript is an independent language and can ...READ MORE

answered Jun 27, 2022 in Web Development by rajatha
• 7,680 points
671 views
0 votes
1 answer

How to automate radio button and checkbox on a webpage in Selenium Webdriver?

Hey Yashmita, following code snippet automates the ...READ MORE

answered Jul 23, 2019 in Selenium by Anvi
• 14,150 points
2,356 views
0 votes
1 answer

How to check a radio button with jQuery?

For versions of jQuery equal or above ...READ MORE

answered Feb 23, 2022 in Java by Aditya
• 7,680 points
582 views
0 votes
1 answer

jQuery checkbox change and click event

Have shared an approach which will add ...READ MORE

answered Feb 23, 2022 in Java-Script by Aditya
• 7,680 points
54,251 views
0 votes
1 answer

Check if checkbox is checked with jQuery

To check whether a Checkbox has been ...READ MORE

answered Jun 23, 2022 in Web Development by rajatha
• 7,680 points
1,386 views
0 votes
1 answer

jQuery get value of selected radio button

Input Radio value Property Get the value of ...READ MORE

answered Jun 23, 2022 in Web Development by rajatha
• 7,680 points
2,709 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP