How to prevent form from being submitted?

后端 未结 10 2346
挽巷
挽巷 2020-11-21 07:06

I have a form that has a submit button in it somewhere.

However, I would like to somehow \'catch\' the submit event and prevent it from occurring.

Is there s

10条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-21 07:35

    var form = document.getElementById("idOfForm");
    form.onsubmit = function() {
      return false;
    }
    

提交回复
热议问题