0
我已经尝试了很多不同的事情,我最终放弃了,并切换到jQuery,但为了我的安心,在这种情况下我将如何撤消eventHandler?目前我现在的方法不起作用。香草javascript表单验证,如何撤消预防默认提交
Front end New Profile Form Validations
var profileForm = document.forms[0];
profileForm.onsubmit = function processForm(eventHandler) {
eventHandler.preventDefault();
if {blah blah blah, my code
}else{
profileForm.submit(function(eventHandler) {
return false;
});
}
重复:http://stackoverflow.com/questions/8664486/javascript-code- to-stop-form-submission – albert
Vanilla意味着没有像jQuery这样的库。如果你想撤消'preventDefault()',为什么不去掉那条线呢? – Oriol
要做的一件好事可能是停止使用'.onsubmit'风格的附件并使用['addEventListener()'](https://developer.mozilla.org/en-US/docs/Web/API /事件目标/的addEventListener)。然后你可以使用它的同伴'removeEventListener()'。否则,你可以'null''.onsubmit' – zero298