I'm having trouble with client-side validation with the nuget foolproof package.
My Model
public class Item {
public int Id { get; set; }
[Required]
public double Quantity { get; set; }
[RequiredIfNotEmpty("Quantity")]
public string LocationCode { get; set; }
public IEnumerable<SelectListItem> LocationList { get; set; }
}
In my View I have
@model IList<MyApp.Models.Item>
<!-- some HTML -->
@for(int i = 0; i < Model.Count; i++)
{
<tr>
<td>
@Html.DropDownListFor(p => p[i].LocationCode, Model[i].LocationList, string.Empty, new { @class = "form-control" })
@Html.ValidationMessageFor(p => p[i].LocationCode)
</td>
<td>
@Html.TextBoxFor(p => p[i].Quantity, new { @class = "form-control"})
@Html.ValidationMessageFor(p => p[i].Quantity)
</td>
</tr>
}
In my _Layout.cshtml I have the following bundles included:
@Scripts.Render("~/bundles/modernizr")
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/bootstrap")
@Scripts.Render("~/bundles/jqueryval")
@RenderSection("scripts", required: false)
And my jqueryval bundle looks like this:
bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
"~/Scripts/jquery.validate*",
//"~/Scripts/MvcFoolproofJQueryValidation.min.js",
"~/Scripts/mvcfoolproof.unobtrusive.min.js"
//"~/Scripts/MvcFoolproofValidation.min.js"
));
In my web.config I have:
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
I've tried different combinations with mvcfoolproof js files, but I simply can't get the client-side validation to work. For the Quantity textbox it is working. Note that Server-side IS working.