[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?
Re: how to validate three checkboxes?
(PaymentBy[0].checked == false) && (PaymentBy[1].checked == false) && (PaymentBy[2].checked == false)
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"/>
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.
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.
Re: how to validate three checkboxes?
but i have a radio button in the middle of the checkboxes.
Re: how to validate three checkboxes?
Why do you let users select both cheque and credit card then?