public IActionResult Index(AjaxValidationModel model) { if (!ModelState.IsValid) { return(PartialView("_Z", model)); } if (model.Name.Length < 3) { ModelState.AddModelError("name", "Name should be longer than 2 chars"); return(PartialView("_Z", model)); } ModelState.Clear(); return(PartialView("_Z")); }
public IActionResult Index(AjaxValidationModel model) { if (!ModelState.IsValid) { return(PartialView("_partialAjaxForm", model)); } // the client could validate this, but allowed for testing server errors if (model.Name.Length < 3) { ModelState.AddModelError("name", "Name should be longer than 2 chars"); return(PartialView("_partialAjaxForm", model)); } ModelState.Clear(); return(PartialView("_partialAjaxForm")); }