validate plugin only validates required first and last tag.
I am trying to validate a shopping cart fore submit and at this point only using the required directive. I am submitting the cart using ajax and I am trying to validate before doing the ajax call. When I call the validate() function, only the first and last tag shows an error. After the errors are shown, the rest of the items do show errors if I tab though them. If I fill out the first and last tag, then the form validates with the rest of the data missing. I have tried putting required as a class and or just text inside the tag but it doesn't seem to make a difference.
cardholder_name and
agreeterms are the tags that work. Here is some code. Thanks.
-
<form id="frm_cccheckou" action="/signup/processCC" method="post" enctype="multipart/form-data">
<input type="hidden" id="clienttoken" value="<?php echo $this->getClientToken() ?>" />
<label for="cardholder_name">Name On Card:</label>
<input type="text" id="cardholder_name" required data-braintree-name="cardholder_name" value="" />
<label for="number">Creadit Card Number:</label>
<input type="text" id="number" required data-braintree-name="number" value="" />
<label>Expireation Month / Year:</label>
<table style="width:150px">
<tr>
<td>
<input type="text" id="expiration_month" class="required" data-braintree-name="expiration_month" maxlength="2" value="" />
</td>
<td style="width:5px">/</td>
<td>
<input type="text" id="expiration_year" class="required" data-braintree-name="expiration_year" maxlength="2" value=""/>
</td>
</tr>
</table>
<div style="display: inline">
<label style="width:100px;">Security Code:</label>
<div style="width:80px;">
<input type="text" id="cvv" class="required" data-braintree-name="cvv" maxlength="4" value=""/>
</div>
</div>
<label for="agreeterms">I agree to the terms and conditions.</label>
<input type="checkbox" class="required" id="agreeterms" class="required" name="agreeterms" value="1" />
<a class="ui-btn">View Terms and Conditions</a>
<input type="button" class="btn_submit_payment" value="Submit Payment" />
</form>
And for the JS.
-
var $wrp = $("#frm_cccheckout");
var validate = $wrp.validate();
var isvalid = validate.form();
if(isvalid) {...}