Form validation with meteor when not listening to a submit event

I have a form where it is required that the user fills in Email, Phone number and a string. I would like to disable my submit button before every field is properly filled in. I tried this jquery validation plugin https://github.com/jzaefferer/jquery-validation for meteor and for the most part it worked just fine and was very easy to follow. My problem is that all of my other functions requires a preventDefault first so that I can do everything else that I want to do with my form, such as for example, insert the currect users id in a specific field in mongo, update every field in the form and so on. To get around this I written code that listens to a click event on the submit button instead of a submit event, which every validation package seems to be doing. Is there any efficient way (preferably with a package) that can do this validation for email and phone-number and when the validation is valid then make it possible to “activate” the click event. As of now I can only get the validation and the rest of my functionality to work separately.

In the client:Template.Applymodal.events({ 'click .applying': function(event, template){ event.preventDefault(); Meteor.call('updateEmailAddress', template.$('#primaryemail').val(), this._id._str); Meteor.call('sendEmail', template.$('#primaryemail').val(), this._id._str); Session.set('done', true); } });

I havent included any validation because I don’t even know where to start. If possible I’d like to keep my current code about the same, and make some sort of validation for the email/phone tied to the ‘click .applying’ event. If the validation is good to go then the rest of my code should work just fine, otherwise my applying event should not work at all. As far as I know I don’t want to make my code listen to the submit event, instead I’d like to be more free to only make the code work with the apply event. Hope this is clear enough. Thanks!

I’ve asked the same question on Stack overflow: http://stackoverflow.com/questions/34352075/form-validation-with-meteor-when-not-listening-to-a-submit-event

Why not just run simple schema validation on each change event and set disable class for submit button based on that ?

Ok thanks, I haven’t used simple schema before (quite new to meteor). I was hoping for a easier way to do it without having to change my code all to much. But if this is the standard way of doing it I will give it a try.