Thread: Form Validation

    #1
  1. No Profile Picture
    marianaandr
    Guest
    Devshed Newbie (0 - 499 posts)
    hi, i'm mariana
    i need to validate the checkbox or a drop out menu in the form.
    I have 3 checkboxes and the user will choose just one, but how do I make sure that the form cannot be submitted unless they checked one of the boxes?
    please, help
    thank you
  2. #2
  3. No Profile Picture
    webcoder
    Guest
    Devshed Newbie (0 - 499 posts)


    You can do a simple 'if' statement like:

    <script>
    function checkIt() {
    if (document.forms[0].check1.checked == false && document.forms[0].check2.checked == false && document.forms[0].check3.checked == false) {
    alert('no');
    }
    else { alert('yes') }
    }
    </script>

    ------------------

    ______________________
    Matthew J. Flynn

    w e b c o d e r
    http://webcoder.net
  4. #3
  5. No Profile Picture
    scollo
    Guest
    Devshed Newbie (0 - 499 posts)
    Mariana:

    I wrote a sample form validation script last week. It demonstrates how the validation works with the FORM tag:

    http://www.devshed.com/Talk/Forums/Forum3/HTML/000018.html

    Also, I would suggest using radio buttons instead of checkboxes if you are trying to enforce selection of only one item.

Similar Threads

  1. Form validation in NN4 when form is in a layer
    By sly001 in forum HTML Programming
    Replies: 1
    Last Post: August 2nd, 2003, 06:13 PM
  2. Form validation of a dynamically created form
    By jeepboy1219 in forum HTML Programming
    Replies: 1
    Last Post: July 11th, 2003, 03:05 PM
  3. Macromedia form validation script - need to check for spaces
    By james555 in forum HTML Programming
    Replies: 6
    Last Post: December 4th, 2002, 01:29 PM
  4. form validation allowing submit on return false...?
    By bakedbean in forum HTML Programming
    Replies: 4
    Last Post: November 8th, 2002, 06:26 PM
  5. try out this code please (js form validation)
    By firepages in forum HTML Programming
    Replies: 0
    Last Post: July 17th, 2000, 01:16 PM

IMN logo majestic logo threadwatch logo seochat tools logo