jquery表单验证不允许字段非必填字段的空间我试过这个但不工作
$(document).ready(function(){
jQuery.validator.addMethod("noSpace", function(value, element) {
return value.indexOf(" ") < 0 && value != "";
}, "No space please and don't leave it empty");
$("form").validate({
rules: {
name: {
noSpace: true
}
}
});
})