SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Aug 2009
    Posts
    159
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    check box validation

    Hi ive the below piece of code, which is displaying a checkbox for each record,
    Im trying to validate it so if no checkboxes are checked I get an error message "you must select at least one checkbox"
    im using CF8

    Code:
     <td colspan="1" align="right"><input type="button" value="Send Invoices &raquo;" onclick="document.checkmail.submit();"></td>
    any tips would be great

  2. #2
    SitePoint Evangelist TommiChi's Avatar
    Join Date
    Oct 2008
    Posts
    440
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    A javascript solution would be to set an integer variable isChecked and traverse all the input tags using a for loop. if the element.type = checkbox and element.checked= true, then add 1 to isChecked. if at the end of the loop isChecked > 0 then throw an error


Bookmarks

Posting Permissions

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