Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ValidationSummary stays visible after errors are corrected?

I have a ValidationSummary that works pretty well, although it doesn't go away after the last of the form errors are rectified.

I'm not sure if this is default behavior or a bug. It seems more towards the latter, since they don't go away after my form has been submitted.

The only thing I suspect might be impacting the functionality is that the form is created through Ajax.BeginForm().

Even still, shouldn't the ValidationSummary disappear right as I hit the submit button?

like image 709
keeehlan Avatar asked Jun 18 '13 00:06

keeehlan


1 Answers

You can make it hide on form submit in your javascript. If you inspect element on your validation summary, you'll notice it changes styles from .validation-summary-valid to .validation-summary-errors if there are any errors. So this makes it easy to hide.

e.g.

$('#formName').submit(function() {
    if ($(this).valid()) { // checks form is valid.
        $('.validation-summary-errors').hide(); // hides it
    }
});
like image 132
mnsr Avatar answered Oct 25 '22 07:10

mnsr