Can anyone tell me why client side validation is not working in my MVC 4 application.
@Scripts.Render("~/bundles/jquery")
@R
For me this was a lot of searching. Eventually I decided to use NuGet instead of downloading the files myself. I deleted all involved scripts and scriptbundles and got the following packages (latest versions as of now)
Then I added these bundles to the BundleConfig file:
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-{version}.js"));
bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
"~/Scripts/jquery.validate.js",
"~/Scripts/jquery.validate.unobtrusive.js",
"~/Scripts/jquery.unobtrusive-ajax.js"));
I added this reference to _Layout.cshtml:
@Scripts.Render("~/bundles/jquery")
And I added this reference to whichever view I needed validation:
@Scripts.Render("~/bundles/jqueryval")
Now everything worked.
Don't forget these things (many people forget them):