Skip to content Skip to sidebar Skip to footer

A Dropdown Validation Error Occurs If No Value Is Selected On The Associated Radio Button

I have a form with two radio buttons: 'Yes' and 'No'. If 'Yes' is selected, the user selects what they want from two drop-down menus. If the user selects 'No', the form's JavaScrip

Solution 1:

Try this.

$( function(){
    $("input[name='discount']").click(function() {
        var isDisabled = (this.value == 'No');
        $("#colour1, #shade1").prop("disabled", isDisabled);

        if(!isDisabled){
             //Please select option is selected
             if($("#colour1")[0].selectedIndex == 0){
                 alert('Please select color');
             }
             //Please select option is selected
             if($("#shade11")[0].selectedIndex == 0){
                 alert('Please select shade');
             }
        }

    });
});

Post a Comment for "A Dropdown Validation Error Occurs If No Value Is Selected On The Associated Radio Button"