JavaScript code to stop form submission

前端 未结 12 2086
感情败类
感情败类 2020-11-21 06:40

One way to stop form submission is to return false from your JavaScript function.

When the submit button is clicked, a validation function is called. I have a case i

12条回答
  •  逝去的感伤
    2020-11-21 06:47

    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().

提交回复
热议问题