<!DOCTYPE html> <html lang="ko"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>jQuery UI 달력</title> <!-- <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"> <script src="https://code.jquery.com/jquery-1.12.4.js"></script> <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> --> <link rel="stylesheet" href="./jquery-ui-1.12.1/jquery-ui.min.css"> <script src="https://code.jquery.com/jquery-1.12.4.js"></script> <script src="./jquery-ui-1.12.1/jquery-ui.min.js"></script> <script src="./jquery-ui-1.12.1/datepicker-ko.js"></script> <script type="text/javascript"> //<![CDATA[ $(function(){ $("#date1").datepicker(); $("#date2").datepicker({ showOn: "button", buttonImage: "images/calendar.gif", buttonImageOnly: false, buttonText: "Select date", dateFormat: 'yymmdd' , beforeShowDay:sundayAndMonday }); $("#date3").datepicker({ onSelect:function(dateText, inst) { console.log(dateText); console.log(inst); } }); }); jQuery(function($){ }); // 특정날짜들 배열 var disabledDays = ["2013-7-9","2013-7-24","2013-7-26"]; // 주말(토, 일요일) 선택 막기 function noWeekendsOrHolidays(date) { var noWeekend = jQuery.datepicker.noWeekends(date); return noWeekend[0] ? [true] : noWeekend; } // 일요일만 선택 막기 function noSundays(date) { return [date.getDay() != 0, '']; } // 이전 날짜들은 선택막기 function noBefore(date){ return noWeekendsOrHolidays(date); if (date < new Date()) return [false]; return [true]; } // 특정일 선택막기 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]; } function sundayAndMonday(date) { var day = date.getDay(); return [(day != 0 && day != 1 && !(date < new Date()) ) ]; } //]]> </script> </head> <body> <h3>jQuer UI 달력</h3> <input type="text" name="date" id="date1" size="12" /> <br/> <input type="text" name="date" id="date2" size="12" /> <br/> <input type="text" name="date" id="date3" size="12" /> <input type="button" value="달력" onclick="$('#date3').datepicker('show');" /> </body> </html>
댓글 ( 4)
댓글 남기기