HTML5 required attribute not working

Form validation is only triggered on the submit event of the form unless you trigger it elsewhere. Do the AJAX there instead, like this:

$(document).ready(function(){
    $('#mycontactform').submit(function(e){
        e.preventDefault();
        $.post("send.php", $(this).serialize(), function(response) {   
            $('#success').html(response);
            //$('#success').hide('slow');
        });
    });
});

Leave a Comment