jquery-validation
jquery-validation copied to clipboard
Able to submit form using Blank Value
Hi @themeteorchef
I am able to submit form if I give some space by pressing keyborad spacebar, How to resolve this issue? I have mentioned required in the rules.
Thanks and Best Regards, Manu
Hi @themeteorchef ,
Any Update on this, How should I resolve this issue?
Thanks and Best Regards, Manu
This would require trimming the value in question. So, given an input, template.find('[name="something"]').value.trim(). The .trim() will eliminate any blank spaces.
Hi @themeteorchef
Its still allowing me blank values and without any giving any validator error message that this value is blank, I have tried this in event, I don't know that if you meant onRendered, Could you please tell me where to check the trim?
BTW - I don't think if I can use template reference onRendered
Thanks and Best Regards, Manu
This would be wherever you're accessing the values from your form to send to the database. E.g.,
$('#example-form').validate({
rules: {
emailAddress: {
required: true,
email: true
}
},
messages: {
emailAddress: {
required: "Please enter an email address.",
email: "Please enter a valid email address."
}
},
submitHandler() {
const email = template.find('[name="emailAddress"]').value.trim();
Meteor.call('addEmail', email, (error, response) => {
if (error) {
console.log(error);
}
});
}
});
Hi @themeteorchef
OK Thanks, I will check it and will get back on this.
Thanks and Best Regards, Manu