我已经在两个输入上实现了远程验证,如果输入无效,则不会删除该消息,除非我重写两个输入有效输入无效
[Required]
[Remote("IsSectionAvailable", "Test", AdditionalFields = "Section", ErrorMessage = "this section already exists in this year", HttpMethod = "POST")]
public Nullable<short> Year { get; set; }
[Required]
[Remote("IsSectionAvailable", "Test", AdditionalFields = "Year", ErrorMessage = "this section already exists in this year", HttpMethod = "POST")]
public string Section { get; set; }
}
}
控制器
public ActionResult IsSectionAvailable(string Section, short? Year)
{
if (!Year.HasValue)
{
return Json(true);
}
return Json(!IsSectionExists(Section, Year.Value));
}