How to prevent form from being submitted?

后端 未结 10 2359
挽巷
挽巷 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:38

    The following works as of now (tested in chrome and firefox):

    where validateMyForm() is a function that returns false if validation fails. The key point is to use the name event. We cannot use for e.g. e.preventDefault()

提交回复
热议问题