2011-05-24 179 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" })); 
     }); 
    });