티스토리 뷰

반응형

case1. input(text) 1개일 때 자동 서브밋을 그대로 이용. (onkeypress 를 넣지 않음)

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

<script>

function check(){

if(!(document.f.pwd.value=="1234"))

return false;

}

</script>


<form action="2.jsp" method="post" name="password" onsubmit="return check()">

<input type="text" name="pwd">

</form>

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






case2. 강제로 input(text) 2개를 만듬. (추천?)

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

<script>

function enter(){

if (event.keyCode == 13)

check();

}


function check(){

if( document.f.pwd.value=="1234")

password.submit();

else

return false;

}

</script>


<form action="2.jsp" method="post" name="password" onsubmit="return check()">

<input type="text" name="pwd" onkeyperss="enter()">

<input type="text" style="display: none;">

</form>

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


댓글
반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
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
글 보관함