• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

validate check box

Guest
Feb 05, 2014 Feb 05, 2014

Copy link to clipboard

Copied

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>

Views

411

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 05, 2014 Feb 05, 2014

Copy link to clipboard

Copied

LATEST

The form has a radio field instead of checkboxes.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation