Simply add a custom validator, and use it like this:
jQuery.validator.addMethod("accept", function(value, element, param) {
return value.match(new RegExp("." + param + "$"));
});
Only numbers:
rules: {
field: { accept: "[0-9]+" }
}
Only letters
rules: {
field: { accept: "[a-zA-Z]+" }
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…