jQuery Validate Uncaught TypeError: Cannot call method 'getAttribute' of undefined

匿名 (未验证) 提交于 2019-12-03 03:05:02

问题:

Given this HTML using jQuery validate

 <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> 

I get this error:

Uncaught TypeError: Cannot call method 'getAttribute' of undefined

回答1:

The 'name' attribute is missing:

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

(This took me a while to figure out so I thought I'd share the question and solution)

Also: Check the comments below, as others have posted other causes for the same exception.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!