本文介绍了ASP.NET中的当年的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试获取日历中的当前年份.现在是2016年,所以我不希望过去的年份,而未来的年份仅需要当前年份...而且月份是6月或任何其他月份,所以我不希望这样做"未来的几个月只需要当前和过去的几个月.如果日历中的2017年是2017年,那么月份是6月或其他月份,则无法选择未来的月份..我们仅根据年份选择当前月份和过去的月份
例如,当前月份是六月,
2016年1月.... 2016年6月

这就是我尝试的

我尝试过的事情:

i try to get current year in calendar.. now year is 2016 so i don''t want past years and future years only want current year ... and also month is June or any other month so i don''t future months only want current and past months . when year 2017 then in calendar must be year 2017 ..when month is June or any other month then not able to select future months .. we only select only current month and past months according to year
e,g, current month is June so
Jan 2016.... June 2016

this is what i try

What I have tried:

<input type="date" ID="fromdate"/>  
    <input type="date" ID="todate"/>  

 <script type="text/javascript">
          $(function () {
              var currentYear = (new Date).getFullYear();
              var currentMonth = (new Date).getMonth() + 1;
              var currentDay = (new Date).getDate();

              $("#fromdate").datepicker({ minDate: new Date((currentYear - 1), 12, 1), dateFormat: 'dd/mm/yy', maxDate: new Date(currentYear, 11, 31) });
          });
  </script>
 <script type="text/javascript">
     $(function () {
         var currentYear = (new Date).getFullYear();
         var currentMonth = (new Date).getMonth() + 1;
         var currentDay = (new Date).getDate();

         $("#todate").datepicker({ minDate: new Date((currentYear - 1), 12, 1), dateFormat: 'dd/mm/yy', maxDate: new Date(currentYear, 11, 31) });
     });
  </script>




但是当我选择日历时,该节目将显示过去的年份和月份以及未来的年份

任何解决方案?




but when i select calendar this show past year and months also and also future years

any solution?

推荐答案




这篇关于ASP.NET中的当年的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 07:47