除非我重写两个输入有效输入无效,否则为什么验证消息不会消失

时间:2018-04-15 19:57:46

标签: c# asp.net-mvc

我已经在两个输入上实现了远程验证,如果输入无效,则不会删除该消息,除非我重写两个输入有效输入无效

    [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));
        }

0 个答案:

没有答案