How can we specify rules for jquery validation plugin by class?

前端 未结 9 1378
一生所求
一生所求 2020-11-27 11:19

The jQuery Validation plugin works great and is very easy to use:

$(\".selector\").validate({
})

Just by setting css classes like \"require

相关标签:
9条回答
  • 2020-11-27 12:13

    $.validator.addMethod("cMaxlength", function(value, element, param) {
    		
    	return $.validator.methods.maxlength.call(this, value, element, param[1]);
    
    }, '{0}');

    0 讨论(0)
  • 2020-11-27 12:17

    $.validator.addMethod("cMaxlength", function(value, element, param) {
    		
    	return $.validator.methods.maxlength.call(this, value, element, param[1]);
    
    }, '{0}');

    0 讨论(0)
  • 2020-11-27 12:21

    Before this you have to include Query file

    $("#myform_name").validate({
        onfocusout: function(element) { $(element).valid(); } ,
        rules:{
           myfield_name: {
              required:true
           },
           onkeyup: false,
           messages: {
              myoffer: "May not be empty"
           }
        }
    });
    
    0 讨论(0)
提交回复
热议问题