Javascript override form onsubmit event not working

前端 未结 4 1339
粉色の甜心
粉色の甜心 2021-01-12 20:20

I am overriding a form submit event like this:

form.onsubmit = function(event) {
  event.preventDefault();

But when I call submit on the fo

4条回答
  •  无人共我
    2021-01-12 21:03

    To prevent the form posting your function must return false.

    form.onsubmit = function(event) {
        event.preventDefault();
        return false;
    }
    

提交回复
热议问题