날짜 형식 입력 받은 값 확인하기
<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에서 해주시기 바랍니다.
| 번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|---|
| 197 | JavaScript | 18년 전 | 5211 | ||
| 196 | HTML | 18년 전 | 3806 | ||
| 195 | 기타 |
|
18년 전 | 6286 | |
| 194 | HTML | 18년 전 | 4097 | ||
| 193 | HTML | 18년 전 | 4918 | ||
| 192 | HTML | 18년 전 | 3935 | ||
| 191 | HTML | 18년 전 | 4472 | ||
| 190 | HTML | 18년 전 | 7323 | ||
| 189 | HTML | 18년 전 | 2871 | ||
| 188 | HTML | 18년 전 | 3374 | ||
| 187 | HTML | 18년 전 | 3300 | ||
| 186 | HTML | 18년 전 | 2975 | ||
| 185 | HTML | 18년 전 | 5463 | ||
| 184 | HTML | 18년 전 | 3358 | ||
| 183 | HTML | 18년 전 | 5337 | ||
| 182 | JavaScript | 18년 전 | 4039 | ||
| 181 | HTML | 18년 전 | 3110 | ||
| 180 | HTML | 18년 전 | 3151 | ||
| 179 | HTML | 18년 전 | 3163 | ||
| 178 | HTML | 18년 전 | 3261 | ||
| 177 | HTML | 18년 전 | 3189 | ||
| 176 | HTML | 18년 전 | 4432 | ||
| 175 | HTML | 18년 전 | 3007 | ||
| 174 | HTML | 18년 전 | 3036 | ||
| 173 | HTML | 18년 전 | 3047 | ||
| 172 | HTML | 18년 전 | 3461 | ||
| 171 | HTML | 18년 전 | 4104 | ||
| 170 | HTML | 18년 전 | 3209 | ||
| 169 | HTML | 18년 전 | 3403 | ||
| 168 | HTML | 18년 전 | 3209 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기