I looked at this SO post and followed what the first answer did and I did the same but I am still not able to see the error showing up.
The relevant part of the model is:
[Display(Name = "Verify13", ResourceType = typeof(Resources.Resource))]
public bool Is13 { get; set; }
The Controller is:
if (registerModel.Is13 == false)
{
ModelState.AddModelError("REGISTER_0", "You must be 13 of age or older to receive email updates.");
return View(registerModel);
}
The part of the view is:
@Html.ValidationSummary(true)
...
@Html.LabelFor(model => model.Is13)
@Html.CheckBoxFor(model => model.Is13)
@Html.ValidationMessage("REGISTER_O")
What am I doing wrong? The rest of the model has attributes on the fields. The entire model is shown below. The error messages (field is required). Every error is showing up except this one.
public class RegisterViewModel
{
[Display(Name = "FirstName", ResourceType = typeof(Resources.Resource))]
[Required(ErrorMessageResourceType = typeof(Resources.Resource),
ErrorMessageResourceName = "FirstNameRequired")]
[StringLength(50, ErrorMessageResourceType = typeof(Resources.Resource),
ErrorMessageResourceName = "FirstNameLong")]
public string FirstName { get; set; }
[Display(Name = "LastName", ResourceType = typeof(Resources.Resource))]
[Required(ErrorMessageResourceType = typeof(Resources.Resource),
ErrorMessageResourceName = "LastNameRequired")]
[StringLength(50, ErrorMessageResourceType = typeof(Resources.Resource),
ErrorMessageResourceName = "LastNameLong")]
public string LastName { get; set; }
[Display(Name = "Email", ResourceType = typeof(Resources.Resource))]
[Required(ErrorMessageResourceType = typeof(Resources.Resource),
ErrorMessageResourceName = "EmailRequired")]
[RegularExpression(".+@.+\\..+", ErrorMessageResourceType = typeof(Resources.Resource),
ErrorMessageResourceName = "EmailInvalid")]
public string Email { get; set; }
[Display(Name = "ConfirmEmail", ResourceType = typeof(Resources.Resource))]
[Required(ErrorMessageResourceType = typeof(Resources.Resource),
ErrorMessageResourceName = "ConfirmEmailRequired")]
[RegularExpression(".+@.+\\..+", ErrorMessageResourceType = typeof(Resources.Resource),
ErrorMessageResourceName = "EmailInvalid")]
public string ConfirmEmailAddress { get; set; }
[Display(Name = "Password", ResourceType = typeof(Resources.Resource))]
[Required(ErrorMessageResourceType = typeof(Resources.Resource),
ErrorMessageResourceName = "PasswordRequired")]
public string Password { get; set; }
[Display(Name = "ConfirmPassword", ResourceType = typeof(Resources.Resource))]
[Required(ErrorMessageResourceType = typeof(Resources.Resource),
ErrorMessageResourceName = "ConfirmPasswordRequired")]
public string ConfirmPassword { get; set; }
[Display(Name = "ZipCode", ResourceType = typeof(Resources.Resource))]
[Required(ErrorMessageResourceType = typeof(Resources.Resource),
ErrorMessageResourceName = "ZipCodeRequired")]
public string ZipCode { get; set; }
public string[] VideoProvider { get; set; }
public IEnumerable<SelectListItem> Items { get; set; }
[Display(Name = "Verify13", ResourceType = typeof(Resources.Resource))]
public bool Is13 { get; set; }