给定这个html使用
jquery验证
<input id="accept-terms" type="checkBox" class="required"/> <label for="accept-terms"> I accept the <asp:HyperLink ID="termsLink" runat="server" Target="_blank">terms and condtions</asp:HyperLink> of sale.</label> <label for="accept-terms" class="error-text">You must accept the terms and conditions before purchasing</label>
我得到这个错误:
Uncaught TypeError: Cannot call method 'getAttribute' of undefined
解决方法
缺少“name”属性:
<input id="accept-terms" name="accept-terms" type="checkBox" class="required"/>
(这花了我一段时间弄清楚,所以我以为我会分享这个问题和解决方案)
另外:检查下面的评论,因为其他人发布了同样例外的其他原因.