title: jQuery If myform.valid() is true then fire another jQuery function?
body: <p>I have a jQuery function that i would like to execute only if the form validation is true <br />
  I have the validation and other jQuery working fine. <br />
  the problem is now both validation and other function are executing same time.
  <br />
  I would like to run the other function only if the form validation is true.
  here is my script</p>
  
  <pre><code>&lt;script&gt;
              $(document).ready(function () {
                  $.validator.addClassRules({
                      fileName: {
                          required: true
                      }
                  });
                  $("#myform").validate();
                  if ($("#myform").valid()) {
                      $(function () {
                          $('#myform').submit(function () {
                              var cboxes = ($('input:checkbox:checked').filter(":checked").length);
                              var nboxes = ($(":checkbox:not(:checked)").length);
                              if ((cboxes &gt; 0) &amp;&amp; (nboxes &gt; 0)) {
                                  confirm('You have Checked only few locations among the List. \n Are you sure, you do not want to Prescribe from the other locations? ');
                              } else if (cboxes == 0) {
                                  alert('Please select atleast One Address \n Where you would prefer to prescribe from.');
                                  return false;
                              }
                              else {
                                  return true;
                              }
                          });
                      });
                  }
              });
  &lt;/script&gt;
  </code></pre>
  
  <p>please advise how can i get this done?</p>