My Name is Kay....

DIY , 먹방 , 개발 , 육아 , 여행 좋아합니다.
AdBlock 사용시 화면이 정상적으로 노출되지 않습니다.
포스팅 관련 문의 및 개발 문의는 Email : wkzkfmxksi@gmail.com

추가 포스팅이 이뤄지지 않는 블로그입니다. 문의는 wkzkfmxksi@gmail.com 으로 연락주세요.
A to Z
2013.08.05 23:05

datepicker 달력

kay
조회 수 6315 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄 첨부
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄 첨부

API Url : http://jqueryui.com/datepicker/   , Document : http://api.jqueryui.com/datepicker/

Test Url : http://www.uhoon.co.kr/test/1876.html


딱히 설명이 필요없는....달력입니다..

다양한 기능이 있지만 개인적으로 주로 사용하는 옵션은 아래와 같습니다..

주로 영문상태를 쓰지만 요일, 월 한글명은 필수옵션은 아닙니다.


<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>datepicker</title>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css"/>
<script>
	$(function() {
		// 기간 설정 타입 1 
		// start Date 설정시 end Date의 min Date 지정
		$( "#startDt" ).datepicker({
			dateFormat: "yy-mm-dd",
			dayNamesMin: [ "일", "월", "화", "수", "목", "금", "토" ],
			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월" ],
			defaultDate: "+1w",
			numberOfMonths: 1,
			changeMonth: true,
			showMonthAfterYear: true ,
			changeYear: true,
			onClose: function( selectedDate ) {
				$( "#endDt" ).datepicker( "option", "minDate", selectedDate );
			}
		}); 
		 // end Date 설정시 start Date max Date 지정
		$( "#endDt" ).datepicker({
			dateFormat: "yy-mm-dd",
			dayNamesMin: [ "일", "월", "화", "수", "목", "금", "토" ],
			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월" ],
			defaultDate: "+1w",
			numberOfMonths: 1,
			changeMonth: true,
			showMonthAfterYear: true ,
			changeYear: true,
			onClose: function( selectedDate ) {
				$( "#startDt" ).datepicker( "option", "maxDate", selectedDate );
			}
		});

		// 기간 설정 타입 2 
		// start Date 설정시 end Date 가 start Date보다 작을 경우 end Date를 start Date와 같게 설정
		$("#startDt").datepicker({
			dateFormat: "yy-mm-dd",
			defaultDate: "+1w",
			numberOfMonths: 1,
			changeMonth: true,
			showMonthAfterYear: true ,
			changeYear: true,
			onClose: function( selectedDate ) {
				if ($( "#endDt" ).val() < selectedDate)
				{
					$( "#endDt" ).val(selectedDate);
				}
			}
		}); 
		// end Date 설정시 end Date 가 start Date 보다 작을 경우 start Date를  end Date와 같게 설정
		$( "#endDt" ).datepicker({
			dateFormat: "yy-mm-dd",
			defaultDate: "+1w",
			numberOfMonths: 1,
			changeMonth: true,
			showMonthAfterYear: true ,
			changeYear: true,
			onClose: function( selectedDate ) {
				if ($("#startDt" ).val() > selectedDate)
				{
					$("#startDt" ).val(selectedDate);
				}
			}
		});


		//날짜
		$( "#date" ).datepicker({
			changeMonth: true ,
			changeYear: true ,
			showMonthAfterYear: true ,
			dateFormat: "yy-mm-dd",
			dayNamesMin: [ "일", "월", "화", "수", "목", "금", "토" ],
			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월" ],
			defaultDate: "+1w",
			numberOfMonths: 1
		}); 
	}); 
</script>
</head>
<body>
<div>
	<label for="날짜">날짜</label><input type="text" id="date" value=""/>
</div>
<div style="padding-top:50px;">
	<label for="기간">기간</label><input type="text" id="startDt" /> ~ <input type="text" id="endDt" />
</div>
</body>
</html>


* 날짜 선택 


datepicker.png


* 기간 선택 

- 시작일 변경시 종료일 min Date 를 시작일로 변경

- 종료일 변경시 시작일의 max Date 를 종료일로 변경 


기간.png


?

List of Articles
번호 분류 제목 글쓴이 날짜 조회 수
54 UI woothemes FlexSlider - 슬라이더 file kay 2014.09.16 286914
53 PlugIn jQuery Plugin For Auto Resizing iFrame - iFrame Resizer file kay 2014.03.10 105642
52 UI SelectBox Option 값 초기화 및 수정 삭제 kay 2013.03.02 36666
51 PlugIn fancyBox - 레이어팝업 (추천) kay 2013.04.16 32412
50 etc 에러 리포팅 , Ajax 디버깅 ( JS , ASP ) - 오류메시지 확인하기 kay 2013.03.08 30638
49 UI animate - 각종 애니메이션 효과 kay 2013.04.11 26330
48 A to Z CheckBox 값 읽어오기 kay 2013.05.06 25268
47 etc Table에 동적 Tr 추가/삭제 하기 kay 2014.02.09 21280
46 PlugIn jquery-syaku.rolling 상하좌우 롤링 ( 자동롤링 , 버튼 ) 10 file kay 2014.02.09 20164
45 UI 스크롤 탑 컨트롤 - scrolltop control kay 2013.05.29 18965
44 PlugIn makisu - 메뉴 접기(?) kay 2013.04.16 18446
43 PlugIn tiptip - 툴팁 kay 2013.04.14 17886
42 PlugIn jQuery Org Chart - 조직도 그리기 file kay 2014.09.01 16616
41 PlugIn 자동 롤링 배너 Jquery 2 file kay 2013.08.07 13883
40 PlugIn Star Rating Plugin - jQuery 별점 주기 2 file kay 2014.05.01 13225
39 PlugIn Smooth Scroll - 스크롤 이동 ( 속도 , 위치 ) 2 file kay 2013.04.06 12680
38 PlugIn poshytip - 툴팁 kay 2013.04.15 11803
37 UI 동적으로 추가된 객체에 datepicker() 적용하기 kay 2013.11.06 10141
36 etc 한글/영어 byte 체크해서 자르기 1 kay 2013.11.30 9704
35 UI select Box option ( 초기화,추가,삭제 ) kay 2013.04.03 9533
Board Pagination Prev 1 2 3 Next
/ 3