2015-11-05 18 views
2

我有兩個文本框中輸入開始日期和結束日期ALLOYUI日期選擇器setter和getter方法

<input type="text" id="startdate"/> 
<input type="text" id="enddate"/> 

我需要兩個簡單的事情

  1. 在開始日期和開始日期的選擇點擊,需要更新 結束日期+7天。需要

格式爲MM/DD/YYYY

因此,如果任何一個點擊開始日期與2015年1月1日,即2015年1月1日,於結束日期應與2015年1月8日

自動設置
  1. 在選擇startdate時,我需要自動打開enddate。

的日期選擇器庫我用了是ALLOYUI日期選擇器3.0版 http://alloyui.com/examples/datepicker/

任何人都可以請記下代碼,請。

傢伙

<script> 
      var datefrom; 
     YUI().use(
    'aui-datepicker', 
    function(Y) { 
    datefrom = new Y.DatePicker(
     { 
     trigger: '#dpfrom', 
     popover: { 
      zIndex: 1 
     }, 
     calendar: { 
       //maximumDate : new Date(today.getFullYear(),today.getMonth()+1,today.getDate()), 
       minimumDate : new Date(), 
       }, 

     on: { 
      selectionChange: function(event) { 

      } 
     } 
     } 
    ); 
    } 
); 


    //console.log(james); 

    </script> 

我發現5月成立的最小和最大日期但我仍然DONOT必須設定結束日期7天爲當前日期的方式。

+0

歡迎來到StackOverflow!請顯示您迄今爲止所嘗試的內容。這個網站是爲問題和答案,而不是請求你:) – Russell

+0

您好羅素別人做你的工作, \t 這是劇本,我需要有最小的日期作爲當前日期使用alloyyui。 #2點擊startdate,我想從今天開始的7天的結束日期 –

+0

YUI()。使用( 'AUI-日期選擇器', 函數(Y){ 新Y.DatePicker( { 觸發: '#frmdate', 酥料餅:{ zIndex的:1 }, \t \t日曆:{ \t \t \t maximumDate:'01/01/2016' \t \t}, 上:{ selectionChange:功能(事件){ 的console.log(event.newSelection) } } } ); } ); –

回答

0

請爲我找到類似的工作。如果你需要任何東西,請定製它。

<input class="form-control" type="text" id="selecteddate" placeholder="Day, Mon dd, yyyy"></input> 

YUI().use(
       'aui-datepicker', 
       function(Y) { 
        var datepicker = new Y.DatePicker(
        { 
        trigger: 'input', 
        popover: { 
         zIndex: 1 
        }, 
        after: { 
         selectionChange: function(event) {      
          event.preventDefault();  
          Y.log(datepicker.getSelectedDates()); 
          var myDate=Y.DataType.Date.addDays(new Date(datepicker.getSelectedDates()),+6);      
          if (myDate.isValid()) {       
           $("#selecteddate").val(myDate); 
          }       
         } 
        } 
        } 
       ); 
       } 
      ); 


    Date.prototype.isValid = function() { 
     // An invalid date object returns NaN for getTime() and NaN is the only 
     // object not strictly equal to itself. 
     return this.getTime() === this.getTime(); 
    };