jQuery Unobtrusive client-side validation of custom attribute

后端 未结 3 1143
闹比i
闹比i 2021-01-02 23:07

I have created a custom validation attribute which works server-side (after form is posted) but I cannot get the validation to work client-side.

The custom attribut

3条回答
  •  南笙
    南笙 (楼主)
    2021-01-02 23:27

    Add this to your Web.config

    
        
       
       
      
    
    

    Cool then try modifying your rule to use the rule below.

    $.validator.unobtrusive.adapters.add("reasonable", ["reasonable"], function (options) {
    options.rules["reasonable"] = "#" + options.params.reasonable;
    options.messages["reasonable"] = options.message;});
    

提交回复
热议问题