1 Reply Latest reply on Feb 5, 2014 12:21 PM by BKBK

    validate check box

    LisaN Level 1

      I have the type file for users to upload file.  If they browse the file, they have  to select the document type from the check box and versus.  This code didn't do what  I want.  Can onyone pls help?

      Thanks

       

       

      <script>

      function validateForm(oForm) {

       

       

      var numChecked = 0;

              for (var idx=0; idx<oForm.doc_type.length; idx++) {

                      if (oForm.doc_type[idx].checked == true) {

                              numChecked++;

                              break;

                      }

              }

       

      if (document.getElementById ("cpc").value.length ! == 0)

                 if (numChecked == 0){

                      alert('Please check at least one checkbox');

                      return false;

              }

       

                           return false;

       

       

       

      }

                //all checked, then return true for submit

                return true;

       

       

      } </script>

       

       

      <form action="index.cfm?action=APrpocess" method="post"  enctype="multipart/form-data" name="form" id="form" onsubmit="return validateForm(this);">

      <input name="cpc" class="upload" type="file" id="cpc" size="20" tabindex="8" />

                <cfloop query="variables.qDocType">

              <input  type="radio" id="doc_type" name="doc_type" size="20" tabindex="3"  value="#id_int#" <cfif id_int eq form.doc_type>checked="checked" </cfif> />#type_var#

           </cfloop>

      </form>