开发者

JQuery Mobile UI DatePicker Change Date Format

I am trying to change the date format in the JQM UI Datepicker.

It's got an input which display's the dates as you change them.

I need it to display in dd/mm/yyyy format.

Can anyone help please?

UPDATE:

I'm trying this, but nothing's changing:

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

  });   
</script>

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

</script>


Try this $.datepicker.formatDate('dd/mm/yyyy');

More reference here


Change the "jquery.ui.datepicker.mobile.js" file

add date format: dateFormat: "dd/mm/yy" Code shown below

//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" }));
        }); 
    });
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜