javascript - form validation with radio buttons and specific errors -


i trying make form validate there radio buttons , textarea. want nothing left empty i.e form should filled. have done radio buttons part of validation if user not select radio button error particular question. can see code here detailed code.

please me out. not getting error textarea.

you didn't write validation 'textarea' block. have updated 1 textarea... add rest validations.

function radiovalidator() {     var showalert = '';     var allformelements = window.document.getelementbyid("formid").elements;     (i = 0; < allformelements.length; i++)      {         if (allformelements[i].type == 'radio')          {             var thisradio = allformelements[i].name;             var thischecked = 'no';             var allradiooptions = document.getelementsbyname(thisradio);                         var problem_desc = document.getelementbyid("problem_desc");              (x = 0; x < allradiooptions.length; x++)             {                  if (allradiooptions[x].checked && thischecked === 'no' && problem_desc.value === "")                  {                      thischecked = 'yes';                      break;                  }              }              var alreadysearched = showalert.indexof(thisradio);             if (thischecked == 'no' && alreadysearched == -1 && problem_desc.value === "")             {             showalert = showalert + thisradio + ' option must selected\n';             }         }else if(allformelements[i].type =='textarea')         {           // add rest of text area validations here            var problem_desc_1 = document.getelementbyid("problem_desc");           if(problem_desc_1.value === "")           {              showalert = showalert + '"services (please specify)" can not blank. \n';           }           }     }     if (showalert !== '')     {     alert(showalert);     return false;     }     else     {     return true;     } } 

Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -