Validation message not removed immediately

Feb 21, 2011 at 6:15 PM

I went through the tutorial up to page 91. Everything is working fine and I am enjoying it.

However, the client side validation message is not removed when I correct the cause of the error.

Thank you for this great work

Feb 23, 2011 at 2:18 PM

ON IE 8 version 8.0.6001.18702 On Windows XP SP2, most of Site.Css does not work prbably, but the validation part works fine.

On FireFox Version 3.0.19 the Site.CSS works fine, but the color effect of the validation part does not work.

Jan 6, 2012 at 11:36 AM

I am also having the same problem with the validation message not clearing immediately.  It isn't performing the client side validation.

I am following the web tutorial, part 6 - "Typing a single letter in the Title field satisfies the validation requirements, so the validation message is immediately removed.".

I have tried it with Chrome, Firefox, and IE - same problem.  I have also downloaded the full project, and this doesn't work as described either.

Interestingly, I have also followed the MvcMovie tutorial, and this does work - and I can't see any differences.

What am I missing?

Jan 6, 2012 at 1:31 PM

I've found the solution.

The project was automatically created with Create.chtml having the following lines:

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

The _Layout.cshtml was automatically created with these lines:

<link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
<script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/modernizr-1.7.min.js")" type="text/javascript"></script>

Unfortunately, the 'Scripts' folder did not contain all of these .js files, so I copied those files over from the full project I downloaded.

Also, the Web.config needed changing.  It had defaulted this section:

        <add key="webpages:Version" value=""/>

But it needed to be:

        <add key="ClientValidationEnabled" value="true"/>
        <add key="UnobtrusiveJavaScriptEnabled" value="true"/>

Jan 25, 2012 at 2:08 PM

I had the same problem, and it was because an old version of jquery is referenced in the tutorial code in Part 3: Views and ViewModels on ASP.NET Tutorial. If you look at the section headed "Using a Layout for common site elements", you'll see that there is a before and after view of _Layout.cshtml.

The before view shows this line that was generated automatically, which is correct:

    <script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")"     

However, the after view had this line instead:

    <script src="@Url.Content("~/Scripts/jquery-1.4.4.min.js")"
You can see the versions are different. As I was following the tutorial, I pasted the example code over the entire contents of _Layout.cshtml, wiping out the correct version. To fix, simply match it up with whatever version of jquery-x.x.x.min.js you have in your Scripts folder.