javascript - Valid values for ModelClientValidationRule ValidationType string? - Stack Overflow

Is there a lsit of what validation rule types are directly available, without having to code a new one?

Is there a lsit of what validation rule types are directly available, without having to code a new one?

e.g.

JQuery.validation has "min(value)"

But I have tried

var rule = new ModelClientValidationRule();
rule.ErrorMessage = ErrorMessage;
rule.ValidationParameters.Add("required", true);
rule.ValidationParameters.Add("min", _minDate);
rule.ValidationType = "min";
yield return rule;

without success.

Are the only options the inherited classes?

Is there a lsit of what validation rule types are directly available, without having to code a new one?

e.g.

JQuery.validation has "min(value)"

But I have tried

var rule = new ModelClientValidationRule();
rule.ErrorMessage = ErrorMessage;
rule.ValidationParameters.Add("required", true);
rule.ValidationParameters.Add("min", _minDate);
rule.ValidationType = "min";
yield return rule;

without success.

Are the only options the inherited classes?

Share Improve this question edited Nov 1, 2018 at 7:46 dove 20.7k14 gold badges86 silver badges108 bronze badges asked Dec 6, 2012 at 9:24 ImmortalStrawberryImmortalStrawberry 6,10116 gold badges86 silver badges133 bronze badges 0
Add a ment  | 

2 Answers 2

Reset to default 5

Taken from jquery documentation, I would suspect you cannot use date type but convert your date to a number and it will probably work.

Refer to Remote Client Side Validation with FluentValidation, you can make use of the existing remote validator by doing

            var rule = new ModelClientValidationRule
            {
                ValidationType = "remote",
                ErrorMessage = message
            };
            rule.ValidationParameters.Add("url", "/api/validation/uniqueemail");

            yield return rule;

I think you can change the type you want to use by specify the ValidationType.

You can get the List of built-in Validation methods. Refer to that table, it includes the required and min you need.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745497370a4630252.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信