dateCalendar/WdatePicker 选择多个日期

时间:2020-12-31 18:05:39

页面代码:

<textarea  id="yyTime"   placeholder="请填入上班日期" name="attendance_day" rows="6" cols="60"  style="resize:none" >{$attendance_day['attendance_day']}</textarea>
<input id="yyTime2"  type="hidden" />


js:

$(document).ready(function(){

var date_string = $("#yyTime").val();
var array_date = date_string.split(';');
selectDays = [];
$.each(array_date,function(index,value){
selectDays.push(value);
});
});


var selectDays = new Array() ; 


$("#yyTime").click(function(){
if(selectDays.length >= 30){
alert("最多选择30个日期");
return;
}
WdatePicker({
el:'yyTime2',
onpicked:function(){
  if(!!!$("#yyTime").val()){
  $("#yyTime").val(this.value) ;
  }else{
  $("#yyTime").val( $("#yyTime").val()+";"+this.value ) ;
  }
  selectDays.push(this.value);
 },
 dateFmt:'yyyy-MM-dd',
 minDate:$("#month").val()+'-01',
 maxDate:$("#month").val()+'-%ld',
 disabledDates: selectDays
});
var date_string = $("#yyTime").val();
var array_date = date_string.split(';');
selectDays = [];
$.each(array_date,function(index,value){
selectDays.push(value);
});
});