I have the following HTML in my view:
@model PatientLookupModel
@if (Model.IsModelInvalid)
{
@Html.ValidationSummary(false, Model.Resources.InvalidFormMessage)
}
@using (Html.BeginForm("Lookup", "Patient", FormMethod.Post, new { role = "form" }))
{
@Html.Label(Model.Resources.PatientFirstNameLabel)
@Html.TextBoxFor(m => m.PatientFirstName, new { @class = "form-control" })
}
My model looks like this:
using RESOURCES = AppResources.Resources;
namespace Models
{
public class PatientLookupModel
{
[Required(ErrorMessageResourceType = typeof(RESOURCES), ErrorMessageResourceName = "Patient_Lookup_PatientFirstNameRequiredMessage")]
public string PatientFirstName { get; set; }
}
}
My BundleConfig looks like this:
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/lib/jquery-{version}.js",
"~/scripts/lib/jquery.unobtrusive*",
"~/Scripts/lib/jquery.validate*",
"~/Scripts/lib/jquery.maskedinput.js"));
The form itself works as expected. When the first name is not entered, the page reloads with the validation summary populated. The problem is that when you type something in the first name input and then it loses focus, an exception is thrown in the browser console:
data
is undefined.
Any ideas?