Jquery 验证问题 - 不适用于某一特定领域
我已经看了几个小时了,我想在拔掉我的头发之前我会在这里问一下。我正在做表单验证。一切都很好,除了一个领域:我确信这是一件愚蠢的事情。
<input name="Credit Card Number" style="width:150px;" title="Credit Card Number" id="billingCC" type="text" class="textboxpg2" maxlength="50" autocomplete="off" onKeyUp="highlightCC(this.value);">
事情就是这样。当我添加所需的类时,它工作得很好。当我尝试添加规则时,它没有发现该字段无效。表单中的其他所有内容,所有其他验证,都工作正常。就这个。我已经在没有 onkeyup javascript 的情况下尝试过,以确保它不会干扰,并且这不是问题。请指出我确信我犯的愚蠢错误。我在错误控制台中没有收到任何信息,除此之外,表单验证正常。谢谢!
规则
billingCC: {
required:true,
creditcard:true,
number: true,
},
消息
billingCC: "Invalid credit card number",
Ive been looking at this for hours and I figure I'll ask here before pulling my hair out. I am doing a form validation. all is well except ONE field: Im sure it is something stupid.
<input name="Credit Card Number" style="width:150px;" title="Credit Card Number" id="billingCC" type="text" class="textboxpg2" maxlength="50" autocomplete="off" onKeyUp="highlightCC(this.value);">
here is the deal. when I just add the required class it works just fine. when I try to add the rule instead, it doesnt find the field invalid. everything else in the form, all other validations, work fine. just this one. I have tried it without the onkeyup javascript to make sure that it wasn't interfering, and its not the issue. please please point out the stupid error i am sure i am making. I am not getting anything in error console, and aside from that the form validates fine. THANKS!
The rule
billingCC: {
required:true,
creditcard:true,
number: true,
},
the message
billingCC: "Invalid credit card number",
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
验证插件使用 name 属性,而不是 id,所以它找不到它。试试这个:
The validate plugin uses the name attribute, not the id, so it's not finding it. Try this: