title: How to call a javascript function on pageload in MVC
body: <p>This is my Java Script function:-</p>
  
  <pre><code>    function ValidatefuneralDate() {
      var today;
      var currentDate = new Date();
      var year = currentDate.getFullYear();
      var month = currentDate.getMonth() + 1;  
      var day = currentDate.getDate();
  
      if (window.location.href.indexOf("en-US") &gt; -1) {
          today = month + '/' + day + '/' + year;
          var selectedDate = $("#Month option:selected").
          val() + '/' + $("#Day option:selected").text() + 
          '/' + $("#Year option:selected").text();
      }
      else {
          today = day + '/' + month + '/' + year;
          var selectedDate = $("#Day option:selected").
          text() + '/' + $("#Month option:selected").
          val() + '/' + $("#Year option:selected").text();
      }
      if ($("#Month option:selected").val()==2)
      {
          $("#Day option[value='31']").hide();
          $("#Day option[value='30']").hide();
          if ($("#Year option:selected").text() == 2016) {
              $("#Day option[value='29']").show();
          }
          else
          {
              $("#Day option[value='29']").hide();
          }
      }
      else if($("#Month option:selected").
      val() == 4 || $("#Month option:selected").
      val() == 6 || $("#Month option:selected").
      val() == 9 || $("#Month option:selected").val() == 11)
      {
          $("#Day option[value='29']").show();
          $("#Day option[value='30']").show();
          $("#Day option[value='31']").hide();
      }
      else
      {
          $("#Day option[value='31']").show();
      }
      if (selectedDate &lt; today) {
          $("#lblFeneralDate").
          html('@Html.R(VirtualPath,"ValidatefuneralDate")');
          return false;
      }
      else { return true;}
    }
  </code></pre>
  
  <p>How can i call this function on page load time on browser? This function should call at the time of <strong>Page Load</strong> how can i do this?
  how can a function bind with the page load?</p>