jquery

Detect form submit jQuery

$("form").submit(function() {
    var val = "";
    if (val === "") {
        return false; //THIS WILL PREVENT FORM TO SUBMIT
    } else {
        return true; //THIS WILL SUBMIT THE FORM
    }
});

You can check form submit event on the webpage using jQuery. We are using .submit() function to detect form submit here in the code snippet. To select form HTML element, we are using tag name 'form' and attaching .submit() function 

Was this helpful?