How do I prevent multiple form submission in .NET MVC without using Javascript?

后端 未结 13 2080
情深已故
情深已故 2020-11-28 02:36

I want to prevent users submitting forms multiple times in .NET MVC. I\'ve tried several methods using Javascript but have had difficulties getting it to work in all browser

相关标签:
13条回答
  • 2020-11-28 03:21

    Just to complete the answer of @Darin, if you want to handle the client validation (if the form has required fields), you can check if there's input validation error before disabling the submit button :

    $('#myform').submit(function () {
        if ($(this).find('.input-validation-error').length == 0) {
            $(this).find(':submit').attr('disabled', 'disabled');
        }
    });
    
    0 讨论(0)
提交回复
热议问题