I have a simple contact form that I'm using HTML5 form validation on:
input.form-control#email(type='email', name='fromEmail', required='required', value='', placeholder='Email')
To submit the form, I'm doing a JSON post onClick of the submit button. In Firefox, the form validates properly, prompting the user to fill out empty required fields that they have missed. However, in Chrome, clicking on the submit button skips the validation and throws an error. Is there anything I should change to make sure Chrome is paying attention the HTML5 form validation?
$('#submit').on('click', function (argument) {
event.preventDefault();
utils.postJSON('/form', utils.getJsonFromForm("form#contact-form")).done(function (data) {
if (data.error) return;
utils.flash.success("Thanks for contacting us!");
});
});
Any feedback would be very much appreciated.