Question

I have a options variable for the jquery form plugin.

It has a function beforeSubmit. Now i want to validate the form for which i want to stop the execution of the code.

How can i stop jQuery to run the code. Currently i m using throw "error" for example -

var options = { 
beforeSend: function(e) 
{
    $("#progress").show();
    //clear everything
    $("#bar").width('0%');
    $("#message").html("");
    $("#percent").html("0%");
    throw "error";
}, ....

Please see the example here

Regards,

Was it helpful?

Solution 2

jQuery form plugin has an option beforeSubmit like beforeSend...

beforeSubmit: function() {
    return validate();
}

validate() function should return a true to continue or a false to stop execution.

OTHER TIPS

Use preventDefault option to stop propagation. In your case add e.preventDefault(); in first line of your function.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top