title: How do I listen for a date change in JavaScript when using Html.DatePickerFor
body: <p>I have a date input field on a page in my ASP.Net MVC 4 application. I need some client side validation to run when the user changes this date. </p>
  
  <p>The code to generate this field is: </p>
  
  <pre><code>@Html.DatePickerFor(x =&gt; x.EndDate)
  </code></pre>
  
  <p>At the bottom of the same cshtml page as the above code I also have the following:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      MyValidation.FormValidator.initialize($('#EndDate'));
  &lt;/script&gt;
  </code></pre>
  
  <p>And the MyValidation.FormValidator.js file: </p>
  
  <pre><code>MyValidation.FormValidator = (function () {
      return {   
          initialize: function (endDateInput) {
              endDateInput.bind('input', function () {
                  alert("hit");
                  SomeValidationFunction();
              });
          }
       };
  })();
  </code></pre>
  
  <p>I've tried a lot of different ways to write the </p>
  
  <pre><code>endDateInput.bind('input', function () {...}
  </code></pre>
  
  <p>part so that it fires correctly, but none of my attempts have worked. My current effort for example is only causing the validation logic to run if the user types the date in; if the user picks a new date from the popup calender then the validation doesn't fire.</p>
  
  <p>I'm very new to web development, so I'm thinking I'm doing something fundamentally wrong here as this doesn't seem like it should be a hard problem.</p>