我正在尝试在 jQuery 中进行验证,以便只输入数字而不是文本。但我不知道该怎么做。
\$('#id_form').validate(
{
rules: {
name: {
minlength: 2,
required: true
},
surname: {
minlength: 2,
required: true
},
gender: {
required: true
},
pId: {
minlength: 2,
required: true
},
dId: {
minlength: 2,
required: true
}
},
highlight: function(element) {
\$(element).closest('.control-group').removeClass('success').addClass('error');
},
success: function(element) {
element
.text('').addClass('valid')
.closest('.control-group').removeClass('error').addClass('success');
}
});
pId snd dId 应该是数字,如果不显示消息