ASP.Net MVC:我如何通过IClientValidatable检查密码是否强大

时间:2016-10-21 11:02:01

标签: asp.net-mvc custom-attributes

如果我想用我自己的自定义属性类注入客户端验证代码,那么我必须使用IClientValidatable。

这里是IClientValidatable

的示例
public IEnumerable<ModelClientValidationRule> GetClientValidationRules(
        ModelMetadata metadata, ControllerContext context)
    {
        var rule = new ModelClientValidationRule();
        rule.ErrorMessage = FormatErrorMessage(metadata.GetDisplayName());
        rule.ValidationParameters.Add("wordcount", WordCount);
        rule.ValidationType = "maxwords";
        yield return rule;
    }

但是现在我不知道在服务器端代码中写什么,它在客户端生成jquery val代码。所以请给我一些建议。

感谢

0 个答案:

没有答案