Thursday, September 4, 2008

JavaScript : form.submit is not a function

I was just trying to submit an HTML form using document.formname.submit() method and was getting these error on different browser. document.formname.submit is not a function Uncaught TypeError: Property 'submit' of object #HTMLForm element is not a function Thats weird! It worked all the time. I was clueless why JavaScript would behave like this...? Yeah, that was a silly mistake. I didn't realize that I named the submit button as 'submit' and that why javascript is failing. We may do this kind of mistakes every now and then...

8 comments:

c# said...

Not only you make silly mistakes. Thanks!

guls_guys said...

great, silly mistake

a href="document.form1.submit()"

input type="submit" name="submit"

above code wont work because there are more than one submit so make sure you dont name your input same as default/native submit();

thanks again

Ruben Reyes said...

wow... I have been banging my head with this error for 3 days.

Thank you so much!

Juan Manuel Vallejo said...

Thank you very much! i would've never seen that, saved me a lot of time :)

Anonymous said...

Thanks You have find out atlast...

Its was simple mistak, But Its complex to decode.. Great Job !!!!

Anonymous said...

THANKS A LOT!!! :)

Marija said...

Thank you, man!

ajaijamwal said...

Thanks a lot dude :-) That saved my time :-)