When I submit this form, I’m quickly getting an “object is not a function” error (in Chrome), while the form submits. What’s my bug?
I’m sure it’s something silly, but for the life of me I don’t understand what’s wrong here.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The other answers are correct, but you can avoid all this hassle by using jQuery more properly.
Instead of inline JavaScript inside the form tag, add ID to the form then have such code:
The form now should look like this:
And don’t forget to add the
return false;to the function itself to prevent submission.When inside the function, JS will treat
validateproperly as a function – when inline inside the form tag, it looked first in the form elements and found the button – hence the error you got.