// 添加自定义校验规则,校验正整数
jQuery.validator.addMethod("positiveinteger", function(value, element) {
var Val = parseInt(value);
return Val > 0 && (Val + "") == value;
}, "请输入正整数"); // 表单验证
$('#rebate_num_form').validate({
errorPlacement: function(error, element) {
$(element).next('.field_notice').hide();
$(element).parent().append(error);
},
success: function(label) {
label.addClass('right').text('OK!');
},
onkeyup: false,
rules: {
num: {
required: true,
number: true,
positiveinteger: true
}
},
messages: {
num: {
required: '不能为空',
number: '只能是数字',
positiveinteger: '只能是正整数'
}
}
});