Jquery 验证
我在一个表单上使用 jquery.validate.js ,该表单正常工作,除了用户可以选择通过支票或信用卡付款的区域之外。 根据选择的选项,将显示隐藏的 div。
通过支票:
<div class="accordionButton">
<label for="Cheque"><input onclick="javascript: $('#li_buttons').show('slow');" type="radio" name="payby" id="cheque" value="Cheque"/>Pay by Cheque</label>
</div>
通过信用卡:
<div class="accordionButton">
<label for="Credit Card"><input onclick="javascript: $('#li_buttons').show('slow');" type="radio" name="payby" id="credit" value="Credit Card" />Pay by Credit Card</label>
</div>
仅当单击单选按钮 (id="credit") 时,我才需要验证信用卡。 因此,我使用类添加了以下内联规则(我只包含了部分代码):
<div class="accordionContent"><label class="description" for="card_name">Cardholder's Name </label>
<li><input id="card_name" name="card_name" class="required #credit:checked" type="text" value="" /></li>
<label class="description" for="free_quarter">Credit Card Type</label>
<li><select "id="card_type" name="card_type" class="required #credit:checked">
<option value="">Select</option>
<option value="visa">Visa</option>
<option value="mastercard">MasterCard</option>
<option value="am_ex">Am Ex</option>
</select></li>
发生的困难是,即使已选择支票作为付款方式,它也会进行验证,因此在没有信用卡信息的情况下不会提交正在提供..
我做错了什么?
干杯并非常感谢您对此提供的任何帮助。
I'm using jquery.validate.js on a form which is working as it should except for an area where users can choose between paying by cheque, or credit card. Depending on which option is chosen, a hidden div will show.
By Cheque:
<div class="accordionButton">
<label for="Cheque"><input onclick="javascript: $('#li_buttons').show('slow');" type="radio" name="payby" id="cheque" value="Cheque"/>Pay by Cheque</label>
</div>
By Credit Card:
<div class="accordionButton">
<label for="Credit Card"><input onclick="javascript: $('#li_buttons').show('slow');" type="radio" name="payby" id="credit" value="Credit Card" />Pay by Credit Card</label>
</div>
I need the credit card validated ONLY if the radio button (id="credit") is clicked. So I added the following inline rules using classes (I've included only some of the code):
<div class="accordionContent"><label class="description" for="card_name">Cardholder's Name </label>
<li><input id="card_name" name="card_name" class="required #credit:checked" type="text" value="" /></li>
<label class="description" for="free_quarter">Credit Card Type</label>
<li><select "id="card_type" name="card_type" class="required #credit:checked">
<option value="">Select</option>
<option value="visa">Visa</option>
<option value="mastercard">MasterCard</option>
<option value="am_ex">Am Ex</option>
</select></li>
What's happening tough, is that it's validating even if Cheque has been chosen as payment method, and therefore won't submit without the credit card info being supplied..
What am I doing wrong?
Cheers and many thanks for any help with this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试这个:
Try this: