How to trim the businessname before validation for a non-required field in the below code. am using [email protected] version to validate the form. for required filed I can able to trim, But I don't have any idea how to trim a non-required field. Thanks in advance
form.validate({
rules: {
firstName: {
required: {
depends:function(){
jQuery(this).val(jQuery.trim(jQuery(this).val()));
return true;
}
},
},
businessName: {
onewordonly: ['1'],
maxlength: 15,
lettersonly: true
},
},
messages: {
firstName: {
required: "Please enter your first name",
},
businessName: {
onewordonly: "bla bla",
maxlength: "bla bla",
lettersonly: "bla bla"
},
},
});
You can use
depends
to execute trim in other parameters likelettersonly
which accepts boolean as value.