I am creating an ASP.NET MVC 5 application. There is a long wait time between the user clicking the "submit" button and the next page to load, so I would like a "please wait" modal to pop up only if the user has submitted a valid form.
I have tried the following code, which causes the modal to pop up no matter if the form is valid or not:
$('form').submit(function () {
$('#waitingModal').show();
});
My application utilizes the jQuery Validate plugin and unobtrusive validation which both came with creating a MVC application, so I tried this code:
$('form').submit(function () {
if ($(this).valid()) {
$('#waitingModal').show();
}
});
But I am getting the following error:
TypeError: $(...).valid is not a function
The NuGet Manager says that I am working with jQuery version 1.11.1, jQuery Validate 1.11.1, and jQuery Unobtrusive 3.2.3.
Am I missing something in my code? Is there another approach?