title: jquery validator addmethod dynamic message
body: <p>I have a custom validation method I am using with the jquery validator.  I am trying to get the error message to be dynamically generated.</p>
  
  <p>I have googled, and the answer I've most seen is shown in <a href="https://stackoverflow.com/questions/1636530/jquery-validator-custom-method">this stackoverflow post</a>.</p>
  
  <p>However, when I try to implement it myself, it doesn't work.  It simply ignores my updated message, and just displays the original message.</p>
  
  <p>Here is my code, located inside the jquery.ready() function.  What am I doing wrong?</p>
  
  <p><em>Note: "g$" is our shorthand for jquery.</em></p>
  
  <pre><code>    var jsBlackoutDateMessage = "Tournaments cannot be scheduled on blackout dates.";
      var jsBlackoutDateMessageFunction = function () {
          return jsBlackoutDateMessage;
      };
      g$.validator.addMethod(
      "notBlackoutDate",
      function (value, element) {
  
          var notBlackoutDate = true;
  
          if (g$.inArray(value, jsBlackoutDates) != -1) {
              notBlackoutDate = false;
          }
  
          if (notBlackoutDate == false) {
  
              // year
              var year = new Date(g$.trim(g$('#txtDate').val())).getFullYear();
  
              var blackoutDatesForYear = jsBlackoutDates.filter(function (item) {
                  return endsWith(item, year.toString());
              })[0];
  
              var blackoutDatesForYearMessage = [];
              blackoutDatesForYearMessage.push("Tournaments cannot be scheduled on blackout dates.");
              blackoutDatesForYearMessage.push("&lt;ul&gt;");
  
              g$.each(blackoutDatesForYear, function (key, value) {
                  blackoutDatesForYearMessage.push("&lt;li&gt;");
                  blackoutDatesForYearMessage.push(new Date(value).toLocaleDateString());
                  blackoutDatesForYearMessage.push("&lt;/li&gt;");
              });
  
              blackoutDatesForYearMessage.push("&lt;/ul&gt;");
  
              jsBlackoutDateMessage = blackoutDatesForYearMessage.join("");
          }
  
          return this.optional(element) || notBlackoutDate;
      },
      jsBlackoutDateMessageFunction
  );
  </code></pre>