There is a form on ASP.NET MVC.
The form displays a model whose properties have certain attributes of standard validation [Required]
When submit form, the validator from standard libraries is activated:

 bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include( "~/Scripts/jquery.unobtrusive*", "~/Scripts/jquery.validate*")); 

When you add a script to the page, which, when you click on the submit button, locks it, and after 2 seconds makes it active, the form submit does not occur, the lock / unlock script itself works as expected, what's the problem? What do you need to add to this script for submit to work successfully?

 $(function() { $(".btn").each(function() { $(this).on("click", function () { var e = $(this); e.attr("disabled", "disabled"); setTimeout(function() { e.removeAttr("disabled"); }, 2000); }); }); }); 

    1 answer 1

    You lock the button before submitting the form.

    Put a short timeout to lock the button with a slight delay:

    And yes, each not needed.

     $(".btn").on("click", function() { var e = $(this); setTimeout(function() { e.attr("disabled", "disabled"); },10); setTimeout(function() { e.removeAttr("disabled"); }, 2000); }); 
    • thanks, it helped - tCode