jQuery验证未捕获的TypeError:无法调用未定义的方法'getAttribute'

时间:2012-09-13 03:26:13

标签: jquery html forms jquery-validate

鉴于此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>

我收到此错误:

  

未捕获的TypeError:无法调用方法&#39; getAttribute&#39;未定义的

1 个答案:

答案 0 :(得分:23)

缺少'name'属性:

<input id="accept-terms" name="accept-terms" type="checkbox" class="required"/> 

(这花了我一段时间才弄清楚,所以我想我会分享问题和解决方案)

另外:检查下面的评论,因为其他人已针对同一例外发布了其他原因。