Form submitted using submit() from a link cannot be caught by onsubmit handler

后端 未结 2 1343
日久生厌
日久生厌 2020-12-03 15:57

Surprised, I am encountering this weird issue while submitting form from JS.

Issue:

Consider a simple form submitted using two ways from a submit

2条回答
  •  無奈伤痛
    2020-12-03 16:35

    Thats how form.submit behaves;

    The form's onsubmit event handler (for example, onsubmit="return false;") will not be triggered when invoking this method from Gecko-based applications. In general, it is not guaranteed to be invoked by HTML user agents

    Make onsubmit call a function and simply call that onclick as well.

提交回复
热议问题