Adding validations to see if radio button is not selected

前端 未结 8 1060
误落风尘
误落风尘 2021-01-07 06:30

I have the following code:

 
  • 1. question 1
  • Strongly
  • 8条回答
    •  抹茶落季
      2021-01-07 06:38

      #by javascript

      function validate(){
      if (checkRadio("question1") && checkRadio("question2") && checkRadio("question3")){
       return true;
      }else{
      alert("Please answer all Questions!");
       return false;
      }
      }
      function checkRadio(name){
       var radio = document.forms.myForm[name];
      for (var option in radio){
      if(radio[option].checked){
       return true;
      }
      }
      return false;
      }
      

    提交回复
    热议问题