Onsubmit event silently killed by onchange

自古美人都是妖i 提交于 2019-12-04 11:46:32

onsubmit works like onclick, which requires onmousedown and onmouseup events consecutively. If your code shows a dialog (eg. alert) or replaces the button after onmouseown event, consequent onmouseup is not fired and thus cancels the event. Swapping the textbox and button with somediv should help.

Ian E

Note that there has been problems with JS engine not running the submit when a dialog box is open: Javascript onchange event preventing onsubmit event in HTML form?

It turns out that it is only presence of an alert() - or a confirm() - during the input's onchange event that causes the form's onsubmit event to not fire. The JS thread appears to get blocked by the alert(). The workaround is to not include any alert() or confirm() in the input's onchange call.

It's likely that they worked around that bug by disallowing alert() or confirm() commands in the onchange call to allow the form to submit as expected.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!