我尝试选择时的Datepicker问题 [英] Datepicker issue when I trying to select
本文介绍了我尝试选择时的Datepicker问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Jquery datepicker
$( function (){
$( ' 。fydate')。datepicker({
dateFormat:' M - yy',
changeMonth: true ,
showButtonPanel: true ,
changeYear: true ,
beforeShow:< span class =code-keyword> function (e,t){
$( this )。datepicker( hide);
$( < span class =code-string>#ui-datepicker-div)。addClass( hide -calendar);
$( #ui-datepicker-div)。addClass(' MonthDatePicker');
$( #ui-datepicker-div)。addClass(' HideTodayButton');
},
onClose: function (dateText,inst){
$( this )。datepicker(' setDate', new Date (inst.selectedYear,inst.selectedMonth, 1 ));
var dd = 1 ;
var mm =(inst.selectedMonth + 1 );
var yyyy = inst.selectedYear;
if (dd< 10 ){
dd = ' 0' + dd
}
if (mm< 10 ){
mm = ' 0' + mm
}
var datetobeset = dd + ' /' + mm + ' /' + yyyy;
$(' #hfFyDate')。val(datetobeset);
}
});
var date = new 日期();
var currentMonth = date.getMonth();
var currentDate = date.getDate();
var currentYear = date.getFullYear();
$( 。fydate)。datepicker( 选项, maxDate , new 日期(currentYear,currentMonth, 0 跨度>));
});
当我第一次选择(它在日期选择器中显示4月2016)日期为2014年5月的文字盒子即将到来5月 - 2014
但是默认情况下再次更改会显示所选日期为2016年4月
我尝试了什么:
尝试搜索谷歌但是如果格式设置为dd / mm / yyyy它的作品
解决方案
( function (){
(' 。fydate')。datepicker({
dateFormat:' M - yy',
changeMonth: true ,
showButtonPanel: true ,
changeYear: true ,
beforeShow:功能(e,t){
( this )。datepicker( 隐藏跨度>);
i am using Jquery datepicker
$(function () { $('.fydate').datepicker({ dateFormat: 'M - yy', changeMonth: true, showButtonPanel: true, changeYear: true, beforeShow: function (e, t) { $(this).datepicker("hide"); $("#ui-datepicker-div").addClass("hide-calendar"); $("#ui-datepicker-div").addClass('MonthDatePicker'); $("#ui-datepicker-div").addClass('HideTodayButton'); }, onClose: function (dateText, inst) { $(this).datepicker('setDate', new Date(inst.selectedYear, inst.selectedMonth, 1)); var dd = 1; var mm = (inst.selectedMonth + 1); var yyyy = inst.selectedYear; if (dd < 10) { dd = '0' + dd } if (mm < 10) { mm = '0' + mm } var datetobeset = dd + '/' + mm + '/' + yyyy; $('#hfFyDate').val(datetobeset); } }); var date = new Date(); var currentMonth = date.getMonth(); var currentDate = date.getDate(); var currentYear = date.getFullYear(); $(".fydate").datepicker("option", "maxDate", new Date(currentYear, currentMonth, 0)); });
when i selecting first time (it shows Apr "2016" in datepicker) date as "May 2014" on text box is coming "MAY - 2014"
but tring to change again by default is shows selected date as "Apr 2016"
What I have tried:
try to search onn google but if format as set as dd/mm/yyyy its works解决方案(function () {
('.fydate').datepicker({ dateFormat: 'M - yy', changeMonth: true, showButtonPanel: true, changeYear: true, beforeShow: function (e, t) {
(this).datepicker("hide");
这篇关于我尝试选择时的Datepicker问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文