I'm new to MVC and trying to do a simple application form with a check box to accept the terms. I cant understand why my error message isnt showing. This is my .cshtml
<div class="form-row">
<div class="validation-container">@Html.ValidationMessageFor(m => m.HasAcceptedTerms)
</div>
<div class="label-container">@Html.LabelFor(m => m.HasAcceptedTerms)</div>
<div class="form-control">@Html.EditorFor(m => m.HasAcceptedTerms)</div>
</div>
my ViewModel
[Required(ErrorMessage = "Please indicate you have read the statements above before sending your request")]
[Display (Name = "Please tick to show you accept all the above statements")]
public bool HasAcceptedTerms
{
get; set;
}
Controller
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult AppForm(AppFormViewModel App)
{
if (ModelState.IsValid)
{
return View();
}
return View(App);
}
When I click the button, the page refreshes with no changes. While debugging, the Model.State
is false
, so I really cant understand why nothing is happening. Does anyone have any ideas?