[英]How to show date without year of jQuery UI datepicker
I need to show date with day and month only, but if I set dateFormat: "d MM"
, I can not change year. 我只需要显示日期和日期,但是如果设置
dateFormat: "d MM"
,则不能更改年份。 It's always 2012. For example: http://jsfiddle.net/v2vcV/ . 它始终是2012年。例如: http : //jsfiddle.net/v2vcV/ 。 Just try change date for January 2013 and reopen calendar, year will be still 2012.
只需尝试更改日期为2013年1月并重新打开日历,年份仍为2012年。
I have made a small change but it gives you Year also, indeed it removes the bug you were facing 我做了一个小的更改,但它也给了您Year,的确消除了您面临的错误
using this resolves problem $( "#datepicker" ).datepicker({dateFormat: "dd MM yy"});
使用此方法可以解决问题
$( "#datepicker" ).datepicker({dateFormat: "dd MM yy"});
You can remove that year logically afterwards when the date is set. 您可以在设置日期后在逻辑上删除该年份。
I have made all edit changes and it works great now.. Check Here 我已完成所有的编辑修改,现在的伟大工程.. 检查这里
Enjoy.. :) 请享用.. :)
This can help you. 这可以为您提供帮助。 HTML
的HTML
<p>Date: <input type="text" style="visibility:hidden; width:0px" id="datepicker2"><input type="text" id="datepicker"></p>
JS JS
$(function() {
$("#datepicker").focus(function(){
$("#datepicker2").focus();
});
$("#datepicker2").datepicker({dateFormat: "dd MM yy",
onSelect:function(date){
$("#datepicker").val(date.substring(0,date.length-4));
}
});
});
Any way this is not the perfect way but can help what you want(as a illusion). 无论如何,这都不是完美的方法,但是可以帮助您想要的(作为一种幻想)。 if you want the exact date with year you can get it from datepicker2 textbox.
如果您想要确切的日期和年份,可以从datepicker2文本框中获取。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.