2011-05-24 129 views
1

我正在嘗試更改JQM UI Datepicker中的日期格式。JQuery Mobile UI DatePicker更改日期格式

它有一個輸入顯示的日期,你改變它們。

我需要它以dd/mm/yyyy格式顯示。

任何人都可以幫忙嗎?

UPDATE:

我想這一點,但什麼也沒有發生變化:

<script> 
    //reset type=date inputs to text 
    $(document).bind("mobileinit", function(){ 
    $.mobile.page.prototype.options.degradeInputs.date = true; 

    }); 
</script> 

<script language="javascript"> 
    $(document).ready(function() { 
     $.datepicker.formatDate('dd/mm/yyyy'); //ADDED HERE 
     $("input[type='submit']").click(function(e) { 
      e.preventDefault(); 
     }); 
    }); 

</script> 
+0

您可能會失敗。一旦創建了控件,它似乎不會讓您進行更改 - 我遇到過類似的問題。 http://stackoverflow.com/questions/5898535/changing-jquery-mobile-date-picker-options – Rob 2011-05-26 19:19:14

回答

2

試試這個$.datepicker.formatDate('dd/mm/yyyy');

更多參考here

+0

我在哪裏插入代碼?我試過就是這樣,沒有什麼改變:查看代碼更新問題。 – Satch3000 2011-05-24 09:09:27

2

更改「jquery.ui.datepicker。 mobile.js「文件

添加日期格式:dateFormat:「dd/mm/yy」代碼如下所示代碼

//bind to pagecreate to automatically enhance date inputs 
    $(".ui-page").live("pagecreate", function(){  
     $("input[type='date'], input[data-type='date']").each(function(){ 
      $(this).after($("<div />").datepicker({ altField: "#" + $(this).attr("id"), showOtherMonths: true, dateFormat: "dd/mm/yy" })); 
     }); 
    });