Using the StringLength (or MaxLength) attribute in ASP.NET MVC, I am not receiving client-side validation

  Kiến thức lập trình

Currently, when using StringLength or MaxLength attribute, it only prevents further text input after the defined limit is reached, but without displaying a validation message.

Code (model):

 [Display(Name = "Naslovnik")]
 [Required(ErrorMessageResourceName = "UI_Validation_RequiredValidator",ErrorMessageResourceType = typeof(ResourceUI))] //custom error message
 [StringLength(20, ErrorMessage = "Naslovnik can be a maximum of 100 characters long.")]
 //[MaxLength(20)]
 public string Naslovnik { get; set; } = string.Empty;

Please suggest how to enable the validation message on the client-side.

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT