Tuesday, 20 August 2013

jQuery unobtrusive Validation don't working

jQuery unobtrusive Validation don't working

I have form in mvc 4 that don't make validation on client side.
The validation happen only only on the server side.
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
<div class="editor-label">
@Html.LabelFor(model => model.Name)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Name)
@Html.ValidationMessageFor(model => model.Name)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Phone)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Phone)
@Html.ValidationMessageFor(model => model.Phone)
</div>
<p>
<input type="submit" value="Send" />
</p>
}
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
the bundle code is:
bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
"~/Scripts/jquery.unobtrusive*",
"~/Scripts/jquery.validate*"));
I also checked the web.config settings:
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
The model I using is:
public class ContactUs
{
[Required]
public string Name { get; set; }
[Required]
public string Phone { get; set; }
}
The page is inside the _Layout file. Scripts version: jquery 2.0.3s and
jQuery Validation Plugin 1.11.1
All the scripts is working and exist on the source code of the page.
What can be the problem?

No comments:

Post a Comment