I have 13 forms and every form with 5 to six inputs.
Below code is working perfectly but have to repeat for all inputs.
$('#formID').validate({
rules:{
inputName:{
required:true,
normalizer: function (value) {
//Trim the value of element for whitespaces
return $.trim(value);
}
}
},
messages:{
inputName: {
required: "Please fill some description"
}
}
});
To trim and validate for each input i tried this so far
$('form input, form textarea').each(function (index, element) {
var testInput =$(element).attr("name");
// console.log(testInput+'ehllo');
$('form').validate({
rules:{
testInput:{
normalizer: function (value) {
//Trim the value of element for whitespaces
return $.trim(value);
}
}
}
});
});
But this isn't working