날짜 형식 입력 받은 값 확인하기
<script language="javascript">
function gogogo() {
var ri = check_date(document.all.year.value,document.all.month.value,document.all.day.value)
if (ri == 0) {
alert('정상적인 형식');
} else if (ri == 1) {
alert('년(?)이 잘못 되었습니다');
} else if (ri == 2) {
alert('월이 잘못 되었습니다');
} else if (ri == 3) {
alert('일이 잘못 되었습니다');
}
}
function check_date(year, month, day) {
var dat_option = year % 4;
year = parseInt(year, 10);
month = parseInt(month, 10);
day = parseInt(day, 10);
if (isNaN(year) == true) { return 1; }
if (year < 1970) { return 1; }
if (isNaN(month) == true) { return 2; }
if (isNaN(day) == true) { return 3; }
if (day < 1 || day > 31) { return 3; }
if (month == 2) {
if (((dat_option == 0) && (day > 29)) || ((dat_option != 0) && (day > 28)) ) { return 3; }
} else if ((month == 4) ||
(month == 6) ||
(month == 9) ||
(month == 11)) {
if (day > 30) { return 3; }
} else if ((month == 1) ||
(month == 3) ||
(month == 5) ||
(month == 7) ||
(month == 8) ||
(month == 10) ||
(month == 12)) {
if (day > 31) { return 3; }
} else {
return 2;
}
return 0;
}
</script>
<input type="text" name="year"> 년
<input type="text" name="month"> 월
<input type="text" name="day"> 일
<input type="button" value="확인" onclick="gogogo();"><div class='small'>[이 게시물은 관리자님에 의해 2011-10-31 17:16:08 PHP & HTML에서 이동 됨]</div>
function gogogo() {
var ri = check_date(document.all.year.value,document.all.month.value,document.all.day.value)
if (ri == 0) {
alert('정상적인 형식');
} else if (ri == 1) {
alert('년(?)이 잘못 되었습니다');
} else if (ri == 2) {
alert('월이 잘못 되었습니다');
} else if (ri == 3) {
alert('일이 잘못 되었습니다');
}
}
function check_date(year, month, day) {
var dat_option = year % 4;
year = parseInt(year, 10);
month = parseInt(month, 10);
day = parseInt(day, 10);
if (isNaN(year) == true) { return 1; }
if (year < 1970) { return 1; }
if (isNaN(month) == true) { return 2; }
if (isNaN(day) == true) { return 3; }
if (day < 1 || day > 31) { return 3; }
if (month == 2) {
if (((dat_option == 0) && (day > 29)) || ((dat_option != 0) && (day > 28)) ) { return 3; }
} else if ((month == 4) ||
(month == 6) ||
(month == 9) ||
(month == 11)) {
if (day > 30) { return 3; }
} else if ((month == 1) ||
(month == 3) ||
(month == 5) ||
(month == 7) ||
(month == 8) ||
(month == 10) ||
(month == 12)) {
if (day > 31) { return 3; }
} else {
return 2;
}
return 0;
}
</script>
<input type="text" name="year"> 년
<input type="text" name="month"> 월
<input type="text" name="day"> 일
<input type="button" value="확인" onclick="gogogo();"><div class='small'>[이 게시물은 관리자님에 의해 2011-10-31 17:16:08 PHP & HTML에서 이동 됨]</div>
게시판 목록
퍼블리셔팁
퍼블리싱과 관련된 유용한 정보를 공유하세요.
질문은 상단의 QA에서 해주시기 바랍니다.
질문은 상단의 QA에서 해주시기 바랍니다.
| 번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|---|
| 1217 | 반응형 | 3년 전 | 3105 | ||
| 1216 | 웹접근성 | 3년 전 | 2498 | ||
| 1215 | CSS | 4년 전 | 4904 | ||
| 1214 | 기타 | 4년 전 | 8363 | ||
| 1213 | CSS | 4년 전 | 3256 | ||
| 1212 | 웹접근성 | 4년 전 | 3644 | ||
| 1211 | CSS |
|
5년 전 | 4121 | |
| 1210 | 기타 | 5년 전 | 3346 | ||
| 1209 | CSS | 5년 전 | 3595 | ||
| 1208 | 기타 | 5년 전 | 3152 | ||
| 1207 | 기타 | 5년 전 | 2894 | ||
| 1206 | CSS |
moviepd
|
5년 전 | 3722 | |
| 1205 | HTML |
moviepd
|
5년 전 | 4386 | |
| 1204 | 기타 | 6년 전 | 7838 | ||
| 1203 | 웹접근성 | 6년 전 | 3014 | ||
| 1202 | 기타 | 6년 전 | 2990 | ||
| 1201 | 기타 | 6년 전 | 4327 | ||
| 1200 | 기타 | 6년 전 | 4124 | ||
| 1199 | 기타 | 6년 전 | 4135 | ||
| 1198 | 기타 | 6년 전 | 2616 | ||
| 1197 | 기타 | 6년 전 | 2689 | ||
| 1196 | 기타 | 6년 전 | 2471 | ||
| 1195 | 기타 | 6년 전 | 2460 | ||
| 1194 | 기타 | 6년 전 | 3049 | ||
| 1193 | 기타 | 6년 전 | 9237 | ||
| 1192 | 기타 | 6년 전 | 3886 | ||
| 1191 | 기타 | 6년 전 | 6226 | ||
| 1190 | 기타 | 6년 전 | 2445 | ||
| 1189 | 기타 | 6년 전 | 2347 | ||
| 1188 | 기타 | 6년 전 | 1826 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기