0

I'm using Inline Form Validation Engine to validate a form. Now I want to prevent the form submit. I tried something like this :

$("#ws-form").submit(function(){
    return false;
});

$("#quotation-form").submit(function(){
    return false;
});

Preventing form submit works for #ws-form but not for #quotation-form

These forms have almost the same validation:

$("#ws-form").validationEngine('attach',{
    onValidationComplete: function(form, status){
        if(status === true){
            // some treatment
        }
    }
});    

You can find an example of the forms here. My question how can I prevent the submit for this form?

3
  • Why exactly would you need to stop a submit of a valid form? Surely you should modify your validation? Commented Jan 6, 2012 at 12:23
  • I need to prevent the submit because I make an ajax query when the form is valid Commented Jan 6, 2012 at 15:10
  • 1
    Can you add a tag <form onSubmit="return false;"></form> Commented Jan 6, 2012 at 15:16

2 Answers 2

1

If inline validation is not required then you can do the following.

First add a jquery.validate.js file in your header. Then modify the click behavior of the button as follows:

$("#submitButton").live("click",function(){
$("#frm").validate();
if($("#frm").valid())
{
   // ajax call
}
return false;// if required to be on same page.
});
Sign up to request clarification or add additional context in comments.

1 Comment

Inline validation is compulsory for this form :(
0
"ajaxUserCall": {
    "url": "ajaxValidateFieldUser",
    "extraData": "name=eric",
    "extraDataDynamic": ['#user_id', '#user_email'],
    "alertText": "* This user is already taken",
    "alertTextOk": "All good!",
    "alertTextLoad": "* Validating, please wait"
},

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.