如何更改jquery Datepicker的dateformat [英] how to change dateformat of jquery Datepicker

查看:355
本文介绍了如何更改jquery Datepicker的dateformat的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用jQuery 1.5.1和1.8.11 jQueryUI,我遇到了一个非常奇怪的问题。我试过很多东西,行为似乎是一样的。



如果我不想让我的日期加上yy-mm- dd格式。但是,正如所有的例子,我使用的代码(下面),当我开始在文本框上写日期时,我不能输入像2011-03-22这样的东西,因为当我键入前2个(一天)

  $(#txtDTPicker)。datepicker({
altField:# lblPkr,
altFormat:'yy-mm-dd',
dateFormat:'yy-mm-dd',
showOtherMonths:true,
selectOtherMonths:true,
showOn:button,
buttonImage:/images/calendar_icon.gif,
buttonImageOnly:true
});

有没有人有一个想法如何解决这个问题?我只是在格式'yy-mm-dd'上写我的日期,而没有datepicker会决定我在文本框上应该有什么?

解决方案

  $(.selector).datepicker({dateFormat:'yy-mm-dd'}); 

http://docs.jquery.com/UI/Datepicker#option-date格式


i'm using the jquery 1.5.1 and 1.8.11 jQueryUI and i'm getting a very strange problem. i've tried a lot of things and the behaviour seems to be just the same.

what happens if that i whant to get my date addoring the "yy-mm-dd" format according the documentation. but, as all the examples i use the tipical code (below) and when i start writing the date on the textbox, i cannot type some thing like '2011-03-22' because when i type the first 2(of day) the widget assumes automatically the 02 value.

$("#txtDTPicker").datepicker({
    altField: "#lblPkr",
    altFormat: 'yy-mm-dd',
    dateFormat: 'yy-mm-dd',
    showOtherMonths: true,
    selectOtherMonths: true,
    showOn: "button",
    buttonImage: "/images/calendar_icon.gif",
    buttonImageOnly: true
});

Does anyone have an idea how to solve this? what i whant is just write my date on the format 'yy-mm-dd' without the datepicker decide for me what i should have on the textbox?

解决方案

$( ".selector" ).datepicker({ dateFormat: 'yy-mm-dd' });

http://docs.jquery.com/UI/Datepicker#option-dateFormat

这篇关于如何更改jquery Datepicker的dateformat的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆