Sunday, September 16, 2012

JavaScript Error – Submit is not a Function


If you get the JavaScript error “Submit is not a Function” then you are probably trying to call the Form’s Submit() Method, but you also have a button whitch is called Submit. This results in a conflict in the JavaScript becuse the Submit Method is already bound to the button.

The Solution is simply to change the name of the button so that name=”newname” (or what ever you prefer).

10 comments:

  1. This comment has been removed by a blog administrator.

    ReplyDelete
  2. This comment has been removed by a blog administrator.

    ReplyDelete
  3. I had my internship at long island web design and I would say that I'm quite knowledgeable with JS. I would say that naming the button as "namename" isn't advisable. When you write codes, name your button on what it does cause as you pile up the script its gonna get hard tracking and recalling a button name "newname".

    ReplyDelete
    Replies
    1. Thanks for your comment Ryan. For this post, I was more interested in pointing out what parameter to change to resolve the error, but you do raise a valid point.
      A good naming convention can prevent a lot of problems later on. Beware of simply naming a button after its function, as that is what caused this problem in the first place. I usually use a combination of the controls type and its function, so a form submit button will be called “BtnSubmit”.

      Delete
  4. A basic but an important fix to a problem that is common to programmers. I commend you for sharing this, it has an even better explanation than w3school. But I'd prefer naming it as "submitbutton".

    ReplyDelete
  5. I agree with Ryan here. I've had this error several times as well. And I had to learn it the hard way, most especially when you are trying to create a web design for a new company that has trusted your skills in creating their website.

    ReplyDelete
  6. Correct. To keep it short and simple, it only means Java Script needs organized codes. No mistyping of entries, no forgettable names, and absolutely no typographical errors. Sir Carl Bartlett, thanks for this post, and thanks to the commenters for the additional info.

    ReplyDelete
  7. Now I know why I always get that error. That’s funny because I didn’t thought of it that way.

    ReplyDelete
  8. This comment has been removed by a blog administrator.

    ReplyDelete
  9. This comment has been removed by a blog administrator.

    ReplyDelete