title: How to excute code after form validation within Google Tag Manager constrictions?
body: <p>I need to call a tracking code when a form is submit and after it is validated using Google Tag Manager. I do not have direct access to the site code. I can only execute script from Google Tag Manager.</p>
  
  <p>I've searched the <a href="https://stackoverflow.com/questions/15632607/google-tag-manager-calling-datalayer-push-after-validating-the-form">web for an answer</a>, but I could not find something that worked.</p>
  
  <p>I've tried:</p>
  
  <pre><code>jQuery('#formId').on('submit',function(){
      console.log('test');
  })
  </code></pre>
  
  <p>But this prints "test" before the form validates the fields, so if I leave a field blank, it still prints "test".</p>
  
  <p>I've tried different approaches that <a href="https://stackoverflow.com/questions/8638641/submit-form-after-validation-jquery">I found</a>: </p>
  
  <pre><code>jQuery('#formId').on('submit',function(){
      if (jQuery('#formId').valid()){
       console.log('test');
      }
  })
  </code></pre>
  
  <p>or</p>
  
  <pre><code>jQuery('#formId').on('submit',function(){
      if (jQuery(this).valid()){
       console.log('test');
      }
  })
  </code></pre>
  
  <p>or</p>
  
  <pre><code>jQuery('#formId').on('submit',function(event){
      if (jQuery(event).valid()){
       console.log('test');
      }
  })
  </code></pre>
  
  <p>But they all return <code>VM914:2 Uncaught TypeError: jQuery(...).valid is not a function</code></p>
  
  <p>How can I run a script from Google Tag Manager that runs on formsubmit after the form validation?</p>