Apocaliptica61
Apocaliptica61

Reputation: 95

MVC 4 Error with jquery.val

i am having problems with Jquery validation (client side), it was working well i dont know what happen nw it dont work, here i have some screenshot that may help you to understand the problem enter image description here

and here is my layout : enter image description here

and enter image description here

Upvotes: 0

Views: 1956

Answers (2)

keefdeveloper
keefdeveloper

Reputation: 11

Same issue. I started a simple test by creating a VS 2012 MVC 4 internet app (out-of-the-box). I then updated jquery validation and tested. No problems. I then updated jquery (2.1.1) BAM!!!

I tried simply changing the bundle based upon last answer

Changed

        bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
                    "~/Scripts/jquery.unobtrusive*",
                    "~/Scripts/jquery.validate*"));

to

        bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
                       "~/Scripts/jquery.validate.min.js",
            "~/Scripts/jquery.validate.unobtrusive.min.js",
            "~/Scripts/jquery.validate.unobtrusive.bootstrap.min.js"));

And YES that fixed it!

Upvotes: 1

rsobon
rsobon

Reputation: 1022

Please note that in your BundleConfig you include

        BundleTable.Bundles.Add(new ScriptBundle("~/bundles/validate")
            .Include(
                "~/Scripts/jquery.unobtrusive*",
            ));

I believe it should be

        BundleTable.Bundles.Add(new ScriptBundle("~/bundles/validate")
            .Include(
                "~/Scripts/jquery.validate.unobtrusive*",
            ));

You are also missing this file (I can't see it in Solution Explorer):

"~/Scripts/jquery.validate.js",

These are all needed files in the right order for jquery unobtrusive validation with bootstrap. Double check that you have them in the right place.

<script src="jquery-1.10.2.min.js"></script>
<script src="bootstrap.min.js"></script>
<script src="jquery.validate.min.js"></script>
<script src="jquery.validate.unobtrusive.min.js"></script>
<script src="jquery.validate.unobtrusive.bootstrap.min.js"></script>

Try changing your BundleConfig and include all the files in the right order, avoiding the wildcards ({version} and *), try if it works. Then expeeriment and try to get wildcards right. I have something like that in my project:

        BundleTable.Bundles.Add(new ScriptBundle("~/bundles/jquery")
            .Include(
                "~/Scripts/jquery-2.1.1.min.js"
            ));

        BundleTable.Bundles.Add(new ScriptBundle("~/bundles/ui")
            .Include(
                "~/Scripts/bootstrap.min.js"
            ));

        BundleTable.Bundles.Add(new ScriptBundle("~/bundles/validate")
            .Include(
                "~/Scripts/jquery.validate.min.js",
                "~/Scripts/jquery.validate.unobtrusive.min.js",
                "~/Scripts/jquery.validate.unobtrusive.bootstrap.min.js"
            ));

Upvotes: 2

Related Questions