티스토리 뷰

반응형

<예문>

==============================================

<script>
function checkIt(){
if (!document.myForm.pass.value){                     // 자바스크립트 : 빈문자열 -> false 반환
alert("비밀번호를 입력하지 않았습니다.");
document.myForm.focus();
return false;
}
}
</script>

<form action="b.jsp"  onsubmit="return checkIt()">
<table>
<tr><td><input type="password" name="pass"></tr>
</table>
<input type="submit" value="회원탈퇴">
</form>

=============================================================



onsubmit : form 태그 안에서 

form전송을 하기 전에 입력된 데이터의 유효성을 체크하기 위해 사용하는 이벤트.


onsubmit='return false' 이면 do nothing in submit.


----------------------------------------------------------------------------------------------------


input type=submit 클릭시 submit을 진행하는데,

onsubmit="return false" 있으면 진행하지 않음.






<p.s>

=========================


form onsubmit 이벤트 사용시 주의점

http://ismydream.tistory.com/81



form태그 onsubmit의 올바른 사용

http://cions.tistory.com/entry/Form%ED%83%9C%EA%B7%B8-onsubmit%EC%9D%98-%EC%98%AC%EB%B0%94%EB%A5%B8-%EC%82%AC%EC%9A%A9

댓글
반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
TAG
more
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함