If Radio Button is selected, perform validation on Checkboxes

前端 未结 4 1557
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-03 12:05

I\'m trying to work this form so when the first radio button is selected, run a certain validation. When the second radio button is selected, run a different validation, etc

4条回答
  •  误落风尘
    2021-01-03 12:46

    function validateDays() {
        if (document.getElementById("option1").checked == true) {
            alert("You have selected Option 1");
        }
        else if (document.getElementById("option2").checked == true) {
            alert("You have selected Option 2");
        }
        else if (document.getElementById("option3").checked == true) {
            alert("You have selected Option 3");
        }
        else {
            // DO NOTHING
            }
        }
    

提交回复
热议问题