Javascript Error: submit is not a function

Took me a google search to find this one, but for some reason one of my forms was not submitting using javascript.

The reason was the statement “formObj.submit();” in the javascript was colliding (resulting in ambiguity within the browser) with the form button, which was also named “submit”.

ie:


<input type="submit" name="submit" value="Login">

Change the name of the button to "login" or something else more reflective of it's functionality instead of "submit".
javascript:


function submitForm(formId) {
  var formObj = document.getElementById(formId);
  formObj.submit();
}

html:


<a href="http://www.homepage.com"
onclick="submitForm('loginForm'); return false">Login</a>

<form id="loginForm">
<input type="submit" name="login" value="Login">
</form>
VN:F [1.8.4_1055]
Rating: 9.3/10 (12 votes cast)
VN:F [1.8.4_1055]
Rating: +4 (from 4 votes)
Javascript Error: submit is not a function9.31012

89 Responses to “Javascript Error: submit is not a function”

  1. Anonymous says:

    loosely typed?! try NOT TYPED. thanks for the post. saved me some time in dicking with it.

    UN:F [1.8.4_1055]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.4_1055]
    Rating: 0 (from 0 votes)
  2. Anonymous says:

    I feel especially stupid since I’ve actually had the same problem before.

    UN:F [1.8.4_1055]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.4_1055]
    Rating: 0 (from 0 votes)
  3. Anonymous says:

    I was tearing my hair out on this, thanks!

    UN:F [1.8.4_1055]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.4_1055]
    Rating: 0 (from 0 votes)
  4. Jon Lesser says:

    I had a similiar problem when using a form button to call a function on click. The name of the button had to be different fro the function I was calling.

    Did NOT work:
    input type=”button” name=”newGame” value=”New Game” onClick=”newGame(); return false;”

    Did work:
    input type=”button” name=”New Game” value=”New Game” onClick=”newGame(); return false;”

    The error in firefox’s console was “Error: newGame is not a function”

    Thanks for the tip Chovy! You are the top hit when I google, “javascript error “is not a function”"

    UN:F [1.8.4_1055]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.4_1055]
    Rating: 0 (from 0 votes)
  5. Lunamonkey says:

    This has been driving me f-in nuts all morning. Thanks!

    UN:F [1.8.4_1055]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.4_1055]
    Rating: 0 (from 0 votes)
  6. Eric says:

    *punches Javascript in the face*
    Thank you very much for this info.

    UN:F [1.8.4_1055]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.4_1055]
    Rating: 0 (from 0 votes)
  7. Anonymous says:

    yes thanks man, I also had a similair type problem – I had a function and it was calling the first time, but everytime after I was getting the error “userinfo is not a function” it turned out that the function name was clashing with some element id’s – strange but anyway, you need to be careful with the naming conventions!

    UN:F [1.8.4_1055]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.4_1055]
    Rating: 0 (from 0 votes)
  8. Anonymous says:

    Thanks for posting this. I never would have figured this out.

    UN:F [1.8.4_1055]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.4_1055]
    Rating: 0 (from 0 votes)
  9. Mr Nico says:

    Wow blogs are usefull! Amazing news. Well done Chovy!

    UN:F [1.8.4_1055]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.4_1055]
    Rating: 0 (from 0 votes)
  10. Anonymous says:

    Yet another satisfied customer. I had this exact error. Thanks for posting useful information! :)

    UN:F [1.8.4_1055]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.4_1055]
    Rating: 0 (from 0 votes)
  11. Brendan says:

    You are my best friend FOREVER

    UN:F [1.8.4_1055]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.4_1055]
    Rating: 0 (from 0 votes)
  12. Anonymous says:

    I lost about 3 hours having this problem. Finally I found you post and I fixed it. Thanks man…

    UN:F [1.8.4_1055]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.4_1055]
    Rating: 0 (from 0 votes)
  13. Anonymous says:

    thank you! what an annoying error… thank god for bloggers. ;)

    UN:F [1.8.4_1055]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.4_1055]
    Rating: 0 (from 0 votes)
  14. Anonymous says:

    thx a lot for the hint!

    UN:F [1.8.4_1055]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.4_1055]
    Rating: 0 (from 0 votes)
  15. Anonymous says:

    hi, thanks a lot… it’s really work… i wasted half hour still not solve until found this page…:~~

    UN:F [1.8.4_1055]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.4_1055]
    Rating: 0 (from 0 votes)
  16. Anonymous says:

    awesome – i feel so dumb, but this has been tripping me up for a few days off and on. thanks for posting it! (you’re #1 result for “submit is not a function”)

    UN:F [1.8.4_1055]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.4_1055]
    Rating: 0 (from 0 votes)
  17. Anonymous says:

    thanks!

    UN:F [1.8.4_1055]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.4_1055]
    Rating: 0 (from 0 votes)
  18. Anonymous says:

    Thanks… Spend f**king day for this stupid error :p

    UN:F [1.8.4_1055]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.4_1055]
    Rating: 0 (from 0 votes)
  19. Anonymous says:

    I just spent the last 4 hours f’ing around with this issue. Thanks.

    UN:F [1.8.4_1055]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.4_1055]
    Rating: 0 (from 0 votes)
  20. Moebius says:

    Great, great post!
    I spent a month searching for a solution !

    UN:F [1.8.4_1055]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.4_1055]
    Rating: 0 (from 0 votes)
  21. Anonymous says:

    Thanks for the post, I spent over an hour bashing my head against the wall before I bothered to Google it. Yours was the first result, and the only one I needed to look at.

    UN:F [1.8.4_1055]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.4_1055]
    Rating: 0 (from 0 votes)
  22. Anonymous says:

    Thanks for this tip…saved me a lot of head scratching.

    UN:F [1.8.4_1055]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.4_1055]
    Rating: 0 (from 0 votes)
  23. Anonymous says:

    thank you so much for the tip. i have been baffled by this for a few days now and just decided to do a google on the error. fortunately your page popped up first and it took me directly to the answer!

    thanks
    Lura

    UN:F [1.8.4_1055]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.4_1055]
    Rating: 0 (from 0 votes)
  24. Anonymous says:

    Godalmighty, thank you! This was baffling me!

    UN:F [1.8.4_1055]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.4_1055]
    Rating: 0 (from 0 votes)
  25. Anonymous says:

    You rock, thanks for posting this

    UN:F [1.8.4_1055]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.4_1055]
    Rating: 0 (from 0 votes)
  26. chovy says:

    I love providing the feeling of enlightenment :-D

    (at least that’s how I felt when I finally figured it out).

    UN:F [1.8.4_1055]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.4_1055]
    Rating: 0 (from 0 votes)
  27. Peter says:

    My god, thank you so much. Just another reason why I F’n hate JavaScript and it’s million and one quirks.

    You’re a lifesaver. Thanks.

    UN:F [1.8.4_1055]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.4_1055]
    Rating: 0 (from 0 votes)
  28. JustMe says:

    Wasted one hour and a half on this stupid thing.
    Thanx alot for pointing this out. I also came here by firing “submit is not a function” against google.

    UN:F [1.8.4_1055]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.4_1055]
    Rating: 0 (from 0 votes)
  29. Dennis says:

    Dude, you are a savior! I spent almost an hour wrecking my brain about this. Thanks!

    UN:F [1.8.4_1055]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.4_1055]
    Rating: 0 (from 0 votes)
  30. Add my name to the list of grateful people.

    UN:F [1.8.4_1055]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.4_1055]
    Rating: 0 (from 0 votes)
  31. Yep. I too battled away for about an hour on this one.
    Thanks very much

    UN:F [1.8.4_1055]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.4_1055]
    Rating: 0 (from 0 votes)
  32. row1 says:

    OMG thank you so much, I just spent the last hour trying to figure out what was wrong!!!

    UN:F [1.8.4_1055]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.4_1055]
    Rating: 0 (from 0 votes)
  33. Irek Jozwiak says:

    Many thanks, man! You saved me a lot of time!

    UN:F [1.8.4_1055]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.4_1055]
    Rating: 0 (from 0 votes)
  34. André Pinto says:

    You saved my, I had exactly the same problem! Thank You!!!!!!!!!!!!

    André Pinto, Rio de Janeiro – Brasil

    UN:F [1.8.4_1055]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.4_1055]
    Rating: 0 (from 0 votes)
  35. Kail Ceannai says:

    Thanks!

    UN:F [1.8.4_1055]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.4_1055]
    Rating: 0 (from 0 votes)
  36. Andrew says:

    Wow, thanks alot for the help!

    UN:F [1.8.4_1055]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.4_1055]
    Rating: 0 (from 0 votes)
  37. DaFunky says:

    Thanks!

    I’ve been looking for hours before finding your tip.
    I can sleep now :)

    UN:F [1.8.4_1055]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.4_1055]
    Rating: 0 (from 0 votes)
  38. bjand says:

    I had a similar problem.

    Thanx to this blog, I noticed, that
    You have to specify a different name to submit button.
    for example:
    will not work

    will work

    UN:F [1.8.4_1055]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.4_1055]
    Rating: 0 (from 0 votes)
  39. Kwun Yeung says:

    Thanks! You saved me! I spent hours figuring out what the “submit is not a function” means. Finally my codes are working now. I think I will even delete all useless names for the submit buttons to avoid this collision.

    UN:F [1.8.4_1055]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.4_1055]
    Rating: 0 (from 0 votes)
  40. jtuxy says:

    Many thanx !

    UN:F [1.8.4_1055]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.4_1055]
    Rating: 0 (from 0 votes)
  41. Pete O'Bryan says:

    I would like to be the forty-third person to thank you for publishing this discovery with such a googleable page title. BRILLIANT!!! I can go to lunch now.

    UN:F [1.8.4_1055]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.4_1055]
    Rating: 0 (from 0 votes)
  42. Iwan says:

    Thanks for sharing, great job friend.
    Hope to find other useful stuffs like this on your site.

    UN:F [1.8.4_1055]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.4_1055]
    Rating: 0 (from 0 votes)
  43. Johs says:

    THANX!

    UN:F [1.8.4_1055]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.4_1055]
    Rating: 0 (from 0 votes)
  44. Matt Wall says:

    Thanks heaps – been coding for 6+ years and that one stumped me for last 45mins!!

    UN:F [1.8.4_1055]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.4_1055]
    Rating: 0 (from 0 votes)
  45. Gilbert says:

    Thank you. A simple answer to a tricky problem. There is was, a button named form

    UN:F [1.8.4_1055]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.4_1055]
    Rating: 0 (from 0 votes)
  46. Stellan Sjögren says:

    Thanks, I was going crazy on this thing

    UN:F [1.8.4_1055]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.4_1055]
    Rating: 0 (from 0 votes)
  47. Uisce says:

    I’m feeling like a genius — only spent 15 minutes before I googled you up — thanks for the help!

    UN:F [1.8.4_1055]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.4_1055]
    Rating: 0 (from 0 votes)
  48. Jevon says:

    Thanks as well. That “feature” is totally lame. lol Javascript should be more strict!

    UN:F [1.8.4_1055]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.4_1055]
    Rating: 0 (from 0 votes)
  49. MWarner says:

    Excellent! I just wasted over an hour on this. Many dozens of supposedly expert sites and NO HELP. Where do I send flowers?

    UN:F [1.8.4_1055]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.4_1055]
    Rating: 0 (from 0 votes)
  50. Derek Basch says:

    I too wasted an hour of my life on this stupid error. I might as well go smoke 8 packs of Marlboros and waste a few more.

    UN:F [1.8.4_1055]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.4_1055]
    Rating: 0 (from 0 votes)

Leave a Reply