jquery-validation icon indicating copy to clipboard operation
jquery-validation copied to clipboard

Able to submit form using Blank Value

Open manusharma1 opened this issue 9 years ago • 5 comments
trafficstars

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

manusharma1 avatar Jul 10 '16 11:07 manusharma1

Hi @themeteorchef ,

Any Update on this, How should I resolve this issue?

Thanks and Best Regards, Manu

manusharma1 avatar Jul 13 '16 13:07 manusharma1

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.

themeteorchef avatar Jul 13 '16 13:07 themeteorchef

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

manusharma1 avatar Jul 18 '16 14:07 manusharma1

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);
      }
    });
  }
});

themeteorchef avatar Jul 25 '16 12:07 themeteorchef

Hi @themeteorchef

OK Thanks, I will check it and will get back on this.

Thanks and Best Regards, Manu

manusharma1 avatar Jul 27 '16 13:07 manusharma1