How check if html5 form validation is complete

Don't bind to the click event of the submit button simply bind to the submit event of your form:

$('#comment_form').submit(function(e){
    e.preventDefault();
    //submit via ajax
});

It's probably best not to rely on the browser to validate your data, sure using required and pattern is cool and all but i wouldn't depend on it.

Write your own validation into your javascript before the data is sent off to your URL. You could do this with a bit of Regex or you could use many of the jQuery validation plugins available out there such as h5validate or Validation.


You can use the validator's form() function, e.g.

var validator = $("#comment_form").validate(options);
if (validator.form()) {
    // submit with AJAX
}

Tags:

Html

Forms

Jquery