Results 1 to 7 of 7

Thread: [RESOLVED] how to validate three checkboxes?

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 2006
    Posts
    58

    Resolved [RESOLVED] how to validate three checkboxes?

    how do u validate three checkboxeS?
    i can only validate two checkboxes.

    these are the code that i m using to validate two checkboxes. these codes work when i want to validate two checkboxes.
    else if((PaymentBy[0].checked == false) && (PaymentBy[1].checked == false)
    {
    alert('Please state the method of payment');
    return false;
    }

    else{
    return true;
    }

    </script>
    <body>
    <input name="PaymentBy" type="checkbox" value="cash" />
    <input name="PaymentBy" type="checkbox" value="credit card" />
    <input name="PaymentBy" type="checkbox" value="company" />
    <input type="submit" name="submit" value="Submit">
    </body>

    but now, i just want to validate three checkboxes. can someone shine the light over here?

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: how to validate three checkboxes?

    (PaymentBy[0].checked == false) && (PaymentBy[1].checked == false) && (PaymentBy[2].checked == false)

  3. #3

    Thread Starter
    Member
    Join Date
    Jul 2006
    Posts
    58

    Re: how to validate three checkboxes?

    i have tried using that code, but it still does not work. i want to validate the three checkboxes - By Cheque,By CreditCard and By company billing.

    how can i achieve the validation?

    <input name="PaymentBy" type="checkbox" value="cheque" />
    By Cheque
    <label>Bank:
    <input name="NameBank" type="text" />
    </label><br/>
    <label>Cheque No.:
    <input name="ChequeNo" type="text"/>
    </label>
    <input name="PaymentBy" type="checkbox" value="credit card" />
    By Credit Card
    <ul>
    <input name="PaymentBy" type="radio" value="visa" />
    Visa
    <input name="PaymentBy" type="radio" value="masterCard" />
    Master Card
    </ul>

    <label>Credit Card No:
    <input name="CreditCardNo" type="text" />
    </label>
    Expiry Date (dd/yy):
    <input name="ExpiryDate" type="text"/>

    <input name="PaymentBy" type="checkbox" value="companyBilling"/>
    Company Billing

    <label>Name of Contact Person: Mr/ Ms/ Mdm:
    <input name="contactPerson" type="text"/>

  4. #4
    Frenzied Member DeadEyes's Avatar
    Join Date
    Jul 2002
    Posts
    1,196

    Re: how to validate three checkboxes?

    Can the customer use more than one method of payment for a single transaction? If not you should really be using radio buttons or a combo box.

  5. #5
    Frenzied Member
    Join Date
    Jun 2005
    Posts
    1,170

    Re: how to validate three checkboxes?

    Why it is not working with what penegate suggested? It works fine to me. You have to make sure your code is right, just like your other post, your variables on the form and javascript function's were different. If you still want to achieve this, post your code with the form and the javascript function.

  6. #6

    Thread Starter
    Member
    Join Date
    Jul 2006
    Posts
    58

    Re: how to validate three checkboxes?

    but i have a radio button in the middle of the checkboxes.

  7. #7
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: how to validate three checkboxes?

    Why do you let users select both cheque and credit card then?

Posting Permissions

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



Click Here to Expand Forum to Full Width