DataAnnotations validation (Regular Expression) in asp.net mvc 4 - razor view

前端 未结 9 2169
甜味超标
甜味超标 2020-11-28 08:12

The DataAnnotations validator not working in asp.net mvc 4 razor view, when using the special characters in the regular expression.

Model:



        
9条回答
  •  忘掉有多难
    2020-11-28 08:47

    Try this one in model class

        [Required(ErrorMessage = "Enter full name.")]
        [RegularExpression("([A-Za-z])+( [A-Za-z]+)", ErrorMessage = "Enter valid full name.")]
    
        public string FullName { get; set; }
    

提交回复
热议问题