views:

242

answers:

2

I want the JQuery validate plugin to only display the validation messages only upon form submit and not when the focus from a input field is lost. How do i achieve this?

Right now I am following this pattern, which leads to validation after lost focus event:

<html>
<head>
 <script>
  $(document).ready(function(){
    $("#commentForm").validate();
  });
  </script>

</head>
<body>
<form class="cmxform" id="commentForm" method="get" action="">
 <fieldset>
<p>
     <label for="cname">Name</label>
     <em>*</em><input id="cname" name="name" size="25" class="required" minlength="2" />
   </p>
</fieldset>
</form>
</body>
</html>
+1  A: 

You have to change the default option for onfocusout

$(".selector").validate({
   onfocusout: false
})

More options to enable or disable are listed here - http://docs.jquery.com/Plugins/Validation/validate#toptions

Alex Sexton
+1  A: 

You need to disable all three handlers if you wish to receive absolutely no errors before submission:

$('#commentForm').validate({
    onfocusout: false,
    onkeyup: false,
    onclick: false
})
cballou