jQuery.validator.unobtrusive.adapters.addMinMax round trips, doesn't work in MVC3

前端 未结 2 704
旧巷少年郎
旧巷少年郎 2021-01-02 19:25

I am creating a day range validator using DataAnnotations, jQuery.validate and jquery.validate.unobtrusive. I\'ve already read the following: http://bradwilson.typepad.com/

2条回答
  •  天命终不由人
    2021-01-02 19:31

    Reference: http://bradwilson.typepad.com/blog/2010/10/mvc3-unobtrusive-validation.html

    adapters.addMinMax()'s param is orderby this:

    adapterName, minRuleName, maxRuleName, minMaxRuleName, minAttribute, maxAttribute
    

    so you need this:

    jQuery.validator.unobtrusive.adapters.addMinMax('dayrange', '', '', 'dayrange','minlength', 'maxlength');
    
    AND,,,
    
    param.min, param.max be sure to undefine. param is an purely array as: ['111','000'].
    

    so you need:

    var minDate = now.setDate(now.getDate() - param[0]);
    var maxDate = now.setDate(now.getDate() + param[1]);
    

提交回复
热议问题