UPDATE: my question is more about How to prevent the form submit if the validation fails
the link does not solve my problem
just try again what I'm doing: I have a form with a bunch of input fields, and when the user clicks the submit button, it validates the form using the required="required" attribute if the form is not validated. Then I want to stop submitting the form, as you see javascript, it shows a div when the user submits the form.
Hope this clears up.
END UPDATE
How can I stop sending a form to fire if the form check fails?
<input class="form-control" data-val="true" id="SerialNumber" name="SerialNumber" required="required" type="text"> <button type="submit" name="rsubmit" class="btn btn-success">Submit</button> //loading message: $("form").submit(function (e) { $("#loading").show(); });
source share