Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 728
Myster Avatar asked Sep 13 '12 03:09

Myster


1 Answers

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.

like image 54
Myster Avatar answered Oct 20 '22 13:10

Myster