title: After executing javascript function the rest of the code is skipped
body: <p>When the document loads it executes the <code>checkseason()</code> function and then it ignores the rest of the code. Without <code>checkseason()</code> at load the code works correctly for some reason and I need to execute <code>checkseason()</code> at the beginning to apply validation rules to an input field.</p>
  
  <pre><code>$.mask.definitions['~'] = '[+-]';
  $.mask.definitions['x'] = '[0-9]';
  $.mask.definitions['*'] = '[-A-Za-z0-9._\\\/?&amp;=~]';
  
  function checkseason(){
    d = document.getElementById("season").value;
  
    $('#second_form').validate({
      rules: {
        patch: {
          required: true,
          minlength: 4,
          maxlength: 4,
          remote: {
            url: "../checkpatch.php",
            type: "post"
          }
        }
      },
      messages: {
        patch: {
          required: "Please enter patch version.",
          remote: "Patch with this number already exists."
        }
      },
  
    });
  
  
    $('select[name="season"]').on('change', function () {
      if ($(this).val() == "newseasons") {
        $('input[name="patch"]').rules('add', {
          minlength: 4,
          maxlength: 4,
          messages: {
            minlength: "Please enter 3 numbers"
          }
        });
      } else if ($(this).val() == "oldseasons") {
        $('input[name="patch"]').rules('add', {
          minlength: 8,
          maxlength: 9,
          messages: {
            minlength: "Please enter 8 numbers"
          }
        });
      }
    });
  
    if(d==='newseasons'){
      $("#patch").mask("x.xx", {
        placeholder: ""
      });
    }
    else if(d==='oldseasons'){
  
      $("#patch").unmask();
      $("#patch").mask("?x.x.x.xxx", {
        placeholder: ""
      });
    }
  }
  
  
  $(document).ready(function(){
    checkseason();
  
    var config = {
      fillAll: true
    };
  
    document.forms["second_form"].oninput = function(e) {
      var champion = this["champion[]"];
  
      //Force into array
      if (champion[0] === undefined)
        champion = [this["champion[]"]];
  
      var reached = {
        valid: 0,
        unique: 0
      };
  
      var inputs = [].map.call(champion, function(n) {
        return n.value
      }).filter(function(n) {
        return n.length
      });
  
      var valid = [].every.call(champion, function(n, i) {
        n.setCustomValidity("");
        if (config.fillAll) return (reached.valid = i, champions.hasOwnProperty(n.value));
        else return n.value ? (
          reached.valid = i,
          champions.hasOwnProperty(n.value) &gt; -1
          ) : true;
      });
  
      var unique = inputs.slice(0).sort().every(function(n, i, a) {
        reached.unique = inputs.lastIndexOf(n);
        return n != a[i - 1];
      });
  
      //Check for valid champions
      if (!valid) {
        champion[reached.valid].setCustomValidity("This is not a valid champion, please correct this field and resubmit.")
      }
  
      //Check for duplicates
      if (!unique) {
        champion[reached.unique].setCustomValidity("This champion has already been entered.")
      }
  
      this.checkValidity();
    };
  });
  </code></pre>