Prevent submitting multiple forms in MVC 3 with validation

I have a form with many input fields, some with validation. I use the default authentication plugin in MVC 3. If the server response is slow, the user may click to send another time, which may cause unwanted behavior. How to prevent this? I tried to enter the code in the form's .submit event, but this event occurs even if the validation fails.

+7
source share
1 answer

You can check if the check succeeded and disable the submit button:

$(function () { $('form').submit(function () { if ($(this).valid()) { $('input[type="submit"]').attr('disabled', 'disabled'); } }); }); 
+19
source

All Articles