Form submits before it is validated

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #10035530
    ts
    Participant

    Check link with console.log – form submits before it is validated


    #10035533
    Support
    Keymaster

    Hello ts,

    I saw you are preventing the submit of form and doing an ajax. This way you need check the validation of form with checkValidity() function:

    if( $("#orderform")[0].checkValidity() ) {
        console.log('submited!');
    
        // ajax code
    }

    We hope this helps!

    Please try that and let us know if you need further assistance.

    Kind Regards,

    Rodrigo.


    If you are satisfied with Porto HTML and our support, please leave your comment and rating on ThemeForest downloads page. That helps us a lot: https://themeforest.net/downloads


    #10035539
    ts
    Participant

    but when I do that the page reloads?


    #10035541
    Support
    Keymaster

    Hello, add the event.preventDefault(); after the checkValidity.

    $("#orderform").submit(function(event) {
    
    	if( $("#orderform")[0].checkValidity() ) {
    
    		event.preventDefault();

    Please try that and let us know if you need further assistance.

    Kind Regards,

    Jonas


Viewing 4 posts - 1 through 4 (of 4 total)

This topic is marked as "RESOLVED" and can not rceive new replies.