I want to show a loading-icon after submitting the form, but not if the View Model is not valid (I mean jQuery MVC validation).
<input type="submit" class="btn btn-default" value="Register"/>
<div class="work-con"></div>
If I use something like this
$("#myform").submit(function (event) {
// Animate loader
$(".work-con").fadeIn("slow");
});
it works fine, but it shows the icon even if the Model is not valid and the warnings are displayed.
MVC uses jQuery validation. You can use that to check if the form is valid:
$("#myform").submit(function (event) {
var isValid = $('#myForm').valid();
if (isValid) {
// Animate loader
$(".work-con").fadeIn("slow");
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With