jquery - datepicker > SCRIPT

본문 바로가기

사이트 내 전체검색

뒤로가기 SCRIPT

jquery - datepicker

페이지 정보

작성자 관리자 작성일 20-09-18 09:39 조회 7,285 댓글 0

본문

$( "#datepicker" ).datepicker();

 http://api.jqueryui.com/datepicker/#option-altField

  $("#datepicker").datepicker({
    dateFormat: 'yy-mm-dd',
    showOtherMonths: true,
    selectOtherMonths: true,
    changeMonth: true,
    changeYear : true
   
  });

  $.datepicker.setDefaults({
    prevText: '이전 달',
    nextText: '다음 달',
    monthNames: ['1월', '2월', '3월', '4월', '5월', '6월', '7월', '8월', '9월', '10월', '11월', '12월'],
    monthNamesShort: ['1월', '2월', '3월', '4월', '5월', '6월', '7월', '8월', '9월', '10월', '11월', '12월'],
    dayNames: ['일', '월', '화', '수', '목', '금', '토'],
    dayNamesShort: ['일', '월', '화', '수', '목', '금', '토'],
    dayNamesMin: ['일', '월', '화', '수', '목', '금', '토'],
    showMonthAfterYear: true,
    yearSuffix: '년'
  });


 // 주말(토, 일요일) 선택 막기
// beforeShowDay: noWeekendsOrHolidays
 function noWeekendsOrHolidays(date) {
  var noWeekend = jQuery.datepicker.noWeekends(date);
  return noWeekend[0] ? [true] : noWeekend;
  }


 // 특정일 선택막기
//beforeShowDay: disableAllTheseDays
 var disabledDays = [
  "2020-7-6",
  "2020-7-7"
 ];

  // 특정일 선택막기
function disableAllTheseDays(date) {
  var m = date.getMonth(), d = date.getDate(), y = date.getFullYear();
  for (i = 0; i < disabledDays.length; i++) {
  if($.inArray(y + '-' +(m+1) + '-' + d,disabledDays) != -1) {
  return [false];
  }
  }
  return [true];
  }

댓글목록 0

등록된 댓글이 없습니다.

Copyright © neion.co.kr All rights reserved.
PC 버전으로 보기