Asp.Net MVC - Change error class name

前端 未结 3 778
北荒
北荒 2020-12-17 14:49

When I do field validation in Asp.Net MVC, it\'s generated the following error css classes :

  • input-validation-error
  • field-validation-error
3条回答
  •  北荒
    北荒 (楼主)
    2020-12-17 15:31

    I don't know about xVal but as far as the ASP.NET MVC side of things go, if you have a look at the source you'll see there are some static readonly strings that represent these values.

    public static readonly string ValidationInputCssClassName = "input-validation-error";
    public static readonly string ValidationMessageCssClassName = "field-validation-error";
    public static readonly string ValidationSummaryCssClassName = "validation-summary-errors";
    

    So either you edit the source to your liking (which may also fix xVal) or alter the outputting code to use different values somehow.

    If xVal is using jQuery Validation (which I think it does...?) you could change it's default value for the 'errorClass' option. My answer here could help you along that path.

    HTHs,
    Charles

提交回复
热议问题