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:

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

html:

  • Greg

    All I can say is…Thank you so much!

    Took most of my Sunday afternoon to find this solution.Thank you.

  • martin

    GOD ! Thanks !

    this problem took me days!

    Thank you so much !

  • Thanks, glad I could help.

  • Eduardo Rodrigues

    Man,

    thank you sooooo much!!!!!!

    I´ve been over this for hours!!!
    In debug, it would show the form as a form, with the submit method and all… but, error on the call. There was nothing poiting that the submit was being misplaced with the form button that had the same name.

    You were a NINJA to find this out!

    Thank you!!!!!!!!!!

  • saeed

    I am very much thankful to you for your lovely and informative post. It saved alot of my precious time..thank you ..

  • Shailesh Prajpati

    I will just say about this article. – “Amazzing…” . I am PHP Web Developer and this article solved my problem of javascript….
    Thanks Buddy

  • Ben

    OMG THANK YOU SO MUCH! I searched high and low on Google and I finally found this article that saved my insanity. THANK YOU!

  • HTML was stripped out of my previous message.

    I’ll try to use HTML equivs:

    < input type=”checkbox” name=”toggle_all” onclick=”toggle_all();” >

    < input type=”checkbox” name=”toggle_everything” onclick=”toggle_all();” >

  • It’s not only a matter of reserved words, it’s also a matter of element naming conflicts that you do yourself.

    Found out this after a good half hour of scratching my head:

    will trigger a JS error “toggle_all is not a function” BECAUSE toggle_all is the name of the input element.

    this code works:

    because I set the name of the input element to something else than the function name.

    Hope this saves somebody some time.

    best regards,
    Marvelade

  • Pingback: THE FORM-WIDGET COOKBOOK « ขุดคุ้ยเรื่องราว แบ่งปันประสบการณ์

    ()

  • Jonatan

    Thanks men!!!!!!!!!

  • robert

    dang it, i copied some code and it had a button named submit, and i spent
    an hour trying to figure out why the heck my js was broken, thanks for the post

  • ladokt

    THANKS SO MUCH

  • Chris

    AWESOME ! Thank you. Just spent the last two hours trying to figure this one out!

  • Jaime Navarro

    THANK YOU !!!!

  • Meru

    Thank You So Much !!!

  • Srinivas

    Hey!!

    Thanks a lot yaar!! I spent a lot of my time in getting know the error!! Finally got the answer from you!! thanks a lot!! :)

  • DCE

    thank god i did a search on it…lol. saved my life! Thanks

  • Ash

    Thanks! You saved my day!!!

    You rock !!!!

  • Thanks for this, i was going nuts. :-)

  • Steven

    Thanks a lot for providing this information.
    It solved my problem.

  • Jess

    Thankyou! Ive been looking for hours for the reason why my javascript submit isnt working.

    This is it. Thanks

  • Tony

    Thank you for this solution! I’ve been googling this issue for half an hour. Very helpful.

  • r1tman

    I had a submit button named submit and that is what totally jacked my submit code. So all 1001 ways I coded it would never work because document.formname.submit was an object and I guess it found that before finding the submit function? Not sure why but I know what the problem was at least!

    – Rit

  • Thanks, I was starting to get frustrated :)

  • my french isn’t all that great….and your example got truncated COOLDEV, so I’m not sure what you’re trying to show.

  • chovy

    COKE – why don’t you use the javascript debugger in Firefox? just type “javascript:” in the address bar, then reload the page.

  • Coke

    I f$·%ing HATE JAVASCRIPT SO f$·%ing MUCH.

    So incompatible, so weird, you can’t trace the source of the problem quick. Sucks, Sucks and don’t stop sucking.

  • Oscar González

    Thanks!
    Your article is very usefull; In Safari the error is
    Object [object INPUT] (result of expression document.form1.submit) does not allow calls.

  • TracyTrace

    Definitely worth googling this. I wasted about 30 minutes on this before finding your post. Thanks!

  • Marko Tulio corona Pacheco

    Thanks man I love you,

    from Mexico with love

    It took me about 6 huurs to find your blog, Thanks again.It was so simple all time…

    Marko Tulio corona Pacheco

  • jon

    Thanks!! Luckily, I only lost 40 minutes before I found your incredibly useful article.

  • Ian Good

    Thanks for the tip! I spent an hour trying to figure it out before I googled it. I need to learn to google first.

  • I know – first thing I should’ve checked when I got the unexplainable was “reserved words”.

  • Three hours of searchin my codes and javascripts books about this error, thank you so much, you haved my ***
    moty

  • crazy

    dude, you have no idea how much pain that problem caused me… Thanks a billion.

  • Avinash

    gr888888888888 work dude………!!!

  • Ian

    I loooooooooooooooooooooooooooooooove you!

  • Count me as one of the ones you helped. I wasted at least a good hour of my life on this error!

    Ryan

  • Mike

    Thanks so much. I wasted a whole day on this, but I don’t think I’ll make that mistake again.

  • Anonymous

    Thank you so much – that saved me a lot of time and frusteration – very very much obliged!

  • chovy

    You’re welcome!

  • Kevin

    YOU SOLVED MY PROBLEM!

    You rock!

  • Thanks for that. Just saved me hours cause I would not have thought of a name clash!

  • Okay, it got me too. Put me down for 5 hours wasted on a Sunday night :)

    I’m sure it was a good idea at the time, but what a hunk of junk HTML and JavaScript are. Thanks a bunch W3C. And no Bill Gates that doesn’t mean you are right, you don’t play well with others so you are completely invalid.

  • jeconais

    Well, this’ll teach me to use google first rather than try and figure it out myself.

    My wife thanks you for keeping my hair on my head, where it belongs.

  • The Swede

    Thanx man. I just spent the last hour wondering why all funktions but submit() worked fine in my form. And there it was: a button named submit…

  • haval

    THANK YOU!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  • T Grove

    This article is f***ing amazing, I should hire you at my company!! I have been searching all day for this stupid issue. And of course, with DOT syntax it blows my mind that IE supports this method. Submit is an object of the page, in DOT syntax it should be named differently. Thanks Again – you are a life savor!!

    Now, how in the hell to you change all those other stupid f***ing posts on Google so they get it right???