有人可以给我介绍一下如何使用validate
, rules
, required
, depends
。
我有一些部分代码,但不确定它是如何工作的。
$("#form2").validate({
rules: {
firstname: {
required: {
depends: function () {
$(this).val($.trim($(this).val()));
return true;
}
},
minlength: 2
},
$("#form2").validate({
rules: {
firstname: { //This rule applies to the $('#form2 input[name="firstname"]') selector
required: { //This can be a true/false boolean, string, or a complex field using depends.
depends: function () { //depends takes a function pointer that
//returns a value, informing the rule
//if it is required. In this case, always true.
$(this).val($.trim($(this).val()));
return true;
}
},
minlength: 2 // the minimum length of text in the field is 2 characters.
},
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)