묻고답하기
page_full_width" class="col-xs-12" |cond="$__Context->page_full_width">
폼입력 검사 후에 포의 액션 때문에 다음페이지로 가버리는데..
2005.08.10 15:15
자바 스크립트로 폼입력 검사를 한 후 알림창에서 확인을 누르면 폼액션에서 지정한 페이지로
이동을 해버립니다.
아래 코드 보시고 도움 좀 부탁드립니다...
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=euc-kr">
<title>선택입력폼</title>
<!-- 주민등록 번호 입력폼 공백 및 자리수 검사 -->
<SCRIPT LANGUAGE="JAVASCRIPT">
function chkblank() {
chkobj=document.myForm.jumin;
if(blank(chkobj)==false || chkobj.value.length < 12) {
alert("숫자만입력하시고 주민번호 13자리만 입력해주십시요.");
chkobj.value="";
chkobj.focus();
}
}
//공백 체크 함수
function blank(ob) {
var cnt = 0;
for(i=0;i<ob.value.length;i++) {
if(ob.value.substring(i,i+1)==' ') ++cnt;
}
if(cnt>=1) return false;
}
</SCRIPT>
</head>
<body>
<form name='myForm' method='post' action='test01.php'>
<!-- onSubmit='return chkblank() -->
<table border="0" cellpadding="4" cellspacing="1" bgcolor="#CCCCCC" width="623" align="center">
<tr>
<td width="613" height="3" bgcolor="#CCCCCC" colspan="4"></td>
</tr>
<tr>
<td width="99" bgcolor="white" height="34">
<p align="left">신청자명</p>
</td>
<td width="165" bgcolor="white" height="34">
<p><input type=text name=name size="20" maxlength="30" class=input></p>
</td>
<td width="100" bgcolor="white" height="34">주민등록번호</td>
<td width="222" bgcolor="white" height="34">
<p><input type=text name=jumin size="20" maxlength="13" class=input></p>
</td>
</tr>
<tr>
<td width="99" bgcolor="white" height="29">
<p align="left">배기량</p>
</td>
<td width="505" bgcolor="white" height="29" colspan="3">
<p><input type='radio' name='cc' value=1>50cc이하
<input type='radio' name='cc' value=2 checked>100cc이하
<input type='radio' name='cc' value=3>250cc이하
<input type='radio' name='cc' value=4>250cc이상 </p>
</td>
</tr>
<tr>
<td width="99" height="29" bgcolor="white">
<p align="left">사용용도</p>
</td>
<td width="505" height="29" bgcolor="white" colspan="3">
<p><input type='radio' name='sa' value="1" onClick="CheckChoice(this);" checked>출퇴근용
<input type='radio' name='sa' value="2" onClick="CheckChoice(this);">레저및투어용
<input type='radio'+ '+ ' name='sa' value="3" onClick="CheckChoice(this);">배달용
<input type='radio' name='sa' value="4" onClick="CheckChoice(this);">퀵서비스용</p>
</td>
</tr>
<tr>
<td width="613" height="51" colspan="4" bgcolor="white" valign="middle">
<p align="center"><input type='submit' value="보험료산출" OnClick="chkblank()">
</p>
</td>
</tr>
<tr>
<td width="613" colspan="4" height="3" bgcolor="#CCCCCC"></td>
</tr>
</table>
</form>
</body>
</html>
이동을 해버립니다.
아래 코드 보시고 도움 좀 부탁드립니다...
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=euc-kr">
<title>선택입력폼</title>
<!-- 주민등록 번호 입력폼 공백 및 자리수 검사 -->
<SCRIPT LANGUAGE="JAVASCRIPT">
function chkblank() {
chkobj=document.myForm.jumin;
if(blank(chkobj)==false || chkobj.value.length < 12) {
alert("숫자만입력하시고 주민번호 13자리만 입력해주십시요.");
chkobj.value="";
chkobj.focus();
}
}
//공백 체크 함수
function blank(ob) {
var cnt = 0;
for(i=0;i<ob.value.length;i++) {
if(ob.value.substring(i,i+1)==' ') ++cnt;
}
if(cnt>=1) return false;
}
</SCRIPT>
</head>
<body>
<form name='myForm' method='post' action='test01.php'>
<!-- onSubmit='return chkblank() -->
<table border="0" cellpadding="4" cellspacing="1" bgcolor="#CCCCCC" width="623" align="center">
<tr>
<td width="613" height="3" bgcolor="#CCCCCC" colspan="4"></td>
</tr>
<tr>
<td width="99" bgcolor="white" height="34">
<p align="left">신청자명</p>
</td>
<td width="165" bgcolor="white" height="34">
<p><input type=text name=name size="20" maxlength="30" class=input></p>
</td>
<td width="100" bgcolor="white" height="34">주민등록번호</td>
<td width="222" bgcolor="white" height="34">
<p><input type=text name=jumin size="20" maxlength="13" class=input></p>
</td>
</tr>
<tr>
<td width="99" bgcolor="white" height="29">
<p align="left">배기량</p>
</td>
<td width="505" bgcolor="white" height="29" colspan="3">
<p><input type='radio' name='cc' value=1>50cc이하
<input type='radio' name='cc' value=2 checked>100cc이하
<input type='radio' name='cc' value=3>250cc이하
<input type='radio' name='cc' value=4>250cc이상 </p>
</td>
</tr>
<tr>
<td width="99" height="29" bgcolor="white">
<p align="left">사용용도</p>
</td>
<td width="505" height="29" bgcolor="white" colspan="3">
<p><input type='radio' name='sa' value="1" onClick="CheckChoice(this);" checked>출퇴근용
<input type='radio' name='sa' value="2" onClick="CheckChoice(this);">레저및투어용
<input type='radio'+ '+ ' name='sa' value="3" onClick="CheckChoice(this);">배달용
<input type='radio' name='sa' value="4" onClick="CheckChoice(this);">퀵서비스용</p>
</td>
</tr>
<tr>
<td width="613" height="51" colspan="4" bgcolor="white" valign="middle">
<p align="center"><input type='submit' value="보험료산출" OnClick="chkblank()">
</p>
</td>
</tr>
<tr>
<td width="613" colspan="4" height="3" bgcolor="#CCCCCC"></td>
</tr>
</table>
</form>
</body>
</html>