Obsivus
Obsivus

Reputation: 8359

MVC fool proof validation error inside the JS files

I downloaded MVC Fool Proof Validation from http://foolproof.codeplex.com/

Beacuse I am in need of [RequiredIf].

When I installed MVC Fool Proof Validation I recieved three Javascript files

which are these that I am using inside my layout:

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

Problem is that when I check my scripts with Chrome I get the following errors on these these JS files.

   Uncaught TypeError: Cannot read property 'adapters' of undefined mvcfoolproof.unobtrusive.min.js:54
   Uncaught TypeError: Cannot read property 'ValidatorRegistry' of undefined MvcFoolproofValidation.min.js:50

This is the error on the first one

enter image description here

Second error:

enter image description here

I have not even edited anything inside the JS files :S Any solutions is appreciated!

Thanks in advance!

Upvotes: 4

Views: 4277

Answers (3)

Manohar Gudivada
Manohar Gudivada

Reputation: 21

Do the below steps:

  • Step 1:

PM> Install-Package MicrosoftAjax

  • Step 2:

PM> Install-Package MicrosoftMvcAjax.Mvc5

  • Step 3:

Include them in bundleconfig like below:

bundles.Add(new ScriptBundle("~/bundles/mvcFoolProof").Include(
                          "~/Scripts/MicrosoftAjax*",
                          "~/Scripts/MicrosoftMvcAjax*",
                          "~/Scripts/MicrosoftMvcValidation*",
                          "~/Scripts/mvcfoolproof*",
                          "~/Scripts/MvcFoolproofJQueryValidation*",                                            
                          "~/Scripts/MvcFoolproofValidation*"));

Now it should work without any errors.

Upvotes: 1

Alao
Alao

Reputation: 400

Be careful using FoolProof RequiredIf in MVC4.

This works: [RequiredIfTrue("lead_recommendation", ErrorMessage="required")]

This does not: [RequiredIfTrue("lead_recommendation", ErrorMessage="Required")]

I spent hours racking my brain on this.

Upvotes: 1

bart s
bart s

Reputation: 5100

Looks like you included the scripts before you include jQuery. You should include jQuery before these scripts

Upvotes: 3

Related Questions