Languages
[Edit]
EN

JavaScript - stop form submission on validation fails

6 points
Created by:
maryam
1181

In this article, we would like to show you how to stop form submission on validation fails using JavaScript.

Quick solution:

 

Practical example

Edit

In the example below, we handle onsubmit event, returning false when validation fails. That approach stops form submission when it is needed. As example validation, we check if input field has some value.

 

Alternative titles

  1. JavaScript - stop form submission on failed validation
  2. JavaScript - don't submit form on validation fail
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join