M-V-C Fool-proof not working and showing Uncaught error?

547 Views Asked by At

I installed Fool-Proof from nuGet, but its not working uncaught errors.

Install-Package foolproof -Version 0.9.4518

As I installed it, new folder with name Clients Scripts gets added in to my project with three libraries: FoolProof Unobtrusive, FoolProof jQuery Validation and FoolProof Validation. Then I create new bundle in bundle.config and linked with my shared layout.

    public bool active { get; set; }

    [RequiredIf("active", true,ErrorMessage = "Code is Required")]
    public int Code { get; set; }

It's not displaying validation message. Now, when I checked my console I am getting following errors:

enter image description here

1

There are 1 best solutions below

0
Mohsin On

You haven't loaded required js files. Add the following in BundleConfig.js

bundles.Add(new ScriptBundle("~/bundles/mvcfoolproof").Include(
            "~/Scripts/MicrosoftAjax.js",
            "~/Scripts/MicrosoftMvcAjax.js",
            "~/Scripts/MicrosoftMvcValidation.js",
            "~/Client Scripts/mvcfoolproof.unobtrusive.min.js",
            "~/Client Scripts/MvcFoolproofJQueryValidation.min.js",
            "~/Client Scripts/MvcFoolproofValidation.min.js"));

and then include in your View in correct order

@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/jqueryval")
@Scripts.Render("~/bundles/mvcfoolproof")