Validate Check Box

Results 1 to 2 of 2

Thread: Validate Check Box

  1. #1
    Join Date
    Dec 1969

    Default Validate Check Box

    I have a form that has nine checkboxes all labled chkMarket. I need to validate that at least one checkbox is selected. If so, then I can submit the form. If no checkboxes are selected, I want to send a message to the user. Could someone help me out please?<BR><BR>Thanks

  2. #2
    Jason Guest

    Default RE: Validate Check Box

    Try this:<BR><BR>function validateForm(form){<BR>var pass=true;<BR><BR> frm = document.form <BR> elems = frm.elements; <BR> for( elem = 0; elem &#060; elems.length; ++elem ) <BR> { <BR> if ( elems[elem].name.substring(0,3) == &#039;chk&#039; ) <BR> { <BR> if ( elems[elem].checked ) {<BR> pass = true<BR> break <BR> }else{<BR> pass = false}<BR> }<BR> } <BR><BR> if (!pass) {<BR> alert("Please make sure that at least on checkbox is checked.");<BR> return false;<BR> }<BR>}<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts