views:

95

answers:

1

I'm using the jQuery Validation JS

I have two contact forms, the main one that appears on one page only, and a quick-contact that is on all pages.

How can I prevent quick-contact form to show the error messages ONLY on submit (without effecting the other form)

A: 

i havent used the jQ validation myself, however when i do my very basic javascript side validation, i reference the form, and check for a submitted value, for example, say we had a form with and id of myform and then your javascript code would look like:

<form id="myform" method="post" action="...">
<!-- fields go here -->
</form>

//reference the form
var myform = $('form#myform');

// Setup your validation functions here

// Run validation only on submit of the form, returning success or failure.
form.submit(function()) {
     if(function_1() & function_2()...) {
          return true;
     else
          return false;
});

That way the validation code only runs when that particular form is submitted.

Hope that helps :)

Rob