开发者

jQuery form validation, disabling until submitted

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 开发者_如何学JAVAform to show the error messages ONLY on submit (without effecting the other form)


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 :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜