override error message (The value 'xxx' is not valid for Age) when input incorrect data type for input field asp.net mvc

前端 未结 5 500
庸人自扰
庸人自扰 2020-12-30 03:15

I\'ve tried to override error message when input incorrect data type in input field on HTML form. For example I have the model like this.

public class Person         


        
5条回答
  •  梦毁少年i
    2020-12-30 04:10

            if (ModelState["Age"].Errors.Count > 0)
            {
                ModelState["Age"].Errors.Clear();
                ModelState["Age"].Errors.Add("");
            }
    

提交回复
热议问题