Why Form Elements should not be named submit?

后端 未结 3 1641
梦毁少年i
梦毁少年i 2020-12-21 08:23

I figured out through debugging that I should not name any Form Elements name=\"submit\", but even after searching I didn\'t find any good explanation of why?

3条回答
  •  粉色の甜心
    2020-12-21 09:08

    Say your form is named "foo" and you have a field "firstName".

    foo.firstName is that field in the form.

    foo.submit() will submit that form, because submit is a method on forms.

    If you redefine submit to be a form field you overwrite the submit method.

提交回复
热议问题