ASP.NET MVC - Validation Summary and BlockUI

857 Views Asked by At

So I've been blocking the page with a "Loading" message using the following code for a logon page

<input id="submit" type="submit" value="Log On" onclick="block();"/>

If there's an error with the validation though, the block message will stay there forever. What's the best way to present the block message so it takes the validation into account?

1

There are 1 best solutions below

0
On

If the validation is being triggered automatically and stopping the form from posting, I would simply move the block(); call to the forms onsubmit attribute:

<form onsubmit="block();">

This way, it will only trigger when the form submits, rather than when the user clicks the button when the form may be invalid.