ASP.NET MVC 3 Remote Validation set custom error message

前端 未结 1 395
情深已故
情深已故 2021-01-12 03:06

Is there any way to set different errors according with logic in MVC 3.0 remote validation

public ActionResult IsUserEmailExists(string email)
        {
             


        
相关标签:
1条回答
  • 2021-01-12 03:28

    You could return the error message instead of a boolean value:

    return Json("Some custom error message", JsonRequestBehavior.AllowGet);
    

    In this case the model will be considered invalid (the same as if you had returned false) and the string used as error message.

    0 讨论(0)
提交回复
热议问题