So this validation thing I wrote works but for some reason I need to click twice for the form to submit. Any ideas?
$('#signup').submit(function() {
console.log('Clicked');
$('#signup').validate({
rules: {
FNAME: {
required: true,
notPlaceholder: true
},
email: {
required: true,
notPlaceholder: true,
email: true
}
},
errorLabelContainer: "div.error",
submitHandler: function(form) {
$.colorbox({width:"300px", href:'thankyou.html'});
$('#signup').fadeOut();
}
});
return false;
});
thanks
Your
$('#signup').validatecall is inside$('#signup').submit, which means the validator isn’t attached until the first time the user tries to submit the form. As Cybernate pointed out in a comment, moving thevalidatecall before thesubmitcall will attach the validator first.It’s a little confusing;
validateactually sets up validation, rather than performs it right away.Once validation has been set up using
validate, you can actually change yoursubmitcall to look like this: