title: Resume default behavior with callback
body: <p>Before the form can submit, a few checks needs to be made in Javascript. These checks will validate if all the applicable data is captured for this specific section before proceeding (if button is selected as yes and there are no claims submitted, as well as if the client submitted duplicate claims).</p>
  <p>The part where the check is done for duplicate claims comes back with an array of data returned from an Ajax function. If there are any data for this, the form must be prevented from proceeding and a popup is shown - this is working. The part where I'm stuck is that when there is no data (count = 0), I need to trigger a button and the form must proceed (calls Post method of MVC). However, the form is not proceeding to the Post event (resume with default behavior).</p>
  <p>This is what I've done:</p>
  <pre><code>    $(&quot;#btnNext&quot;).on(&quot;click&quot;, function (e) {
      isNextClick = true;
      if ($(&quot;input[name='Claims']:checked&quot;).val() === &quot;Yes&quot; &amp;&amp; claimCount === 0 &amp;&amp; !isClaimFilled()) {
          $('#btnAddClaim').trigger(&quot;click&quot;);
          return false;
      } else if ($(&quot;input[name='Claims']:checked&quot;).val() === &quot;Yes&quot; &amp;&amp; isClaimFilled()) {
          $(&quot;#dialog-claim-error&quot;).modal(&quot;show&quot;);
          return false;
      } else {
          //Lets first check for duplicates
          e.preventDefault();
  
          var result = clientClaimDuplicationCheck(function (isContinue) {
              var claimCount = isContinue.length;
  
              if (claimCount === undefined || claimCount.length == 0) {
                  // array empty or does not exist when callback is done. 0 will be passed to resume default behaviour
                  claimCount = isContinue;
              }
  
              if (claimCount != undefined || claimCount != null) {
                  if (claimCount &gt; 0) {
  
                      $.each(isContinue, function (index, item) {
                          addClaimDuplicateList(claimIndex, item.Desc, item.Year, item.Month);
                      });
                      e.preventDefault();
                      $(&quot;#claimDuplicateList&quot;).show();
                      $(&quot;#dialog-nav-driver-duplicateClaims&quot;).modal(&quot;show&quot;);
                  }
                  else {
                      // Prevent infinite loop
                      $(this).unbind(&quot;click&quot;);
                      
                      //Now submit form, all validation passed - resume default behavior
                      //  $(&quot;#btnNextValidated&quot;).submit();
                      $('#btnNextValidated').trigger(&quot;click&quot;);
                  }
              }
          });
      }
  });
  
  $(&quot;#btnNextValidated&quot;).on(&quot;click&quot;, function (e) {
      $('#ClaimYear').removeClass(&quot;input-validation-error&quot;);
      var span = $(&quot;div&quot;).find(&quot;[data-valmsg-for='ClaimYear']&quot;);
      span.removeClass(&quot;field-validation-error&quot;).text(&quot;&quot;);
  
      setTimeout(ss.isValidPage, 100);
      return true;
  });
  
  function clientClaimDuplicationCheck(callback) {
     // var isContinue;
      //post data to the server
      $.ajax({
          url: &quot;/Service/ClientClaimDuplicationCheck&quot;,
          type: 'POST',
          contentType: &quot;application/json; charset=utf-8&quot;,
          dataType: &quot;json&quot;,
          success: function (data) {
              callback(data);
          },
          error: function (a, b, c) {
              var error = a;
          }
      });
   }
  
       function addClaimDuplicateList(id, name, year, month) {
      $('#showClaimDuplicateList').append('&lt;div id=&quot;claimDuplicateItem' + id + '&quot; data-claim-key=&quot;0&quot; class=&quot;control-label label-heading-3 label-input-claimSubTitle&quot;&gt;' +
          '&lt;div class=&quot;col-lg-12 col-md-12 col-sm-12 col-xs-12&quot;&gt;&lt;ul class=&quot;claimUl&quot;&gt;&lt;li&gt;' + name + ' ' + month + '/' + year + '&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;' +
          '&lt;/div&gt;');
  }
  </code></pre>
  <p>The method that needs to be called when resuming behavior:</p>
  <pre><code>    [HttpPost]
      public ActionResult DriverInformation(DriverInformationViewModel model)
      { //some methods}
  </code></pre>
  <p>Is there a way to resume default behavior and call the Post Method of the button?</p>