|
-
May 21st, 2007, 02:28 AM
#1
Thread Starter
Member
[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?
-
May 21st, 2007, 02:33 AM
#2
Re: how to validate three checkboxes?
(PaymentBy[0].checked == false) && (PaymentBy[1].checked == false) && (PaymentBy[2].checked == false)
-
May 21st, 2007, 04:28 AM
#3
Thread Starter
Member
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"/>
-
May 21st, 2007, 10:47 AM
#4
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.
-
May 21st, 2007, 02:30 PM
#5
Frenzied Member
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.
-
May 22nd, 2007, 12:53 AM
#6
Thread Starter
Member
Re: how to validate three checkboxes?
but i have a radio button in the middle of the checkboxes.
-
May 22nd, 2007, 12:58 AM
#7
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|