datepicker 를 이용해 특정일만 선택하기 > jquery

본문 바로가기

jquery

datepicker 를 이용해 특정일만 선택하기

작성일 15-11-14 15:09

페이지 정보

작성자서방님 조회 271회 댓글 0건

본문

이번에는 특정일만 선택가능한 상태의 달력을 출력시키는 예제입니다. 머.. 예약신청등을 입력받을때 8월 4일, 8월 9일 이런식으로 먼가 무규칙하면서도 불특정한 일자만 입력받기를 원할때 이런 예제가 필요하리라 생각됩니다.


자.. 소스입니다.


01<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" type="text/css">
02<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
03<script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
04<script type="text/javascript">
05$(document).ready(function() {
06    // enableDay 에 입력된 날짜외에는 모두 disable 됩니다.
07    var enableDay = ["4-8-2013", "9-8-2013"];
08    function selectableDays(date) {
09        dummy = date.getDate() + "-" + (date.getMonth() + 1) + "-" + date.getFullYear();
10        if ($.inArray(dummy, enableDay) > -1) {
11            return [true, ""];
12        }
13 
14        return [false, ""];
15    }
16 
17    $("#date").datepicker({
18        dateFormat: 'yy-mm-dd',
19        beforeShowDay: selectableDays
20    });
21 
22});
23</script>
24<div id="d a t e"></div>


참고한 URL : http://gauravganoo.com/tips/js/jquery-enable-disable-datepicker/

참고한 내용에는 주말이나 국경일등을 disable 시키는 로직도 포함되어 있네요..

댓글목록

등록된 댓글이 없습니다.

게시물 검색
Copyright © 서방님.kr All rights reserved.
PC 버전으로 보기