메모

form input onsubmit...펌

맘편한넘 2012. 6. 19. 16:17

form onsubmit 사용하기 HTML/J.S/CSS

2010/10/31 02:33

복사 http://blog.naver.com/artiba/140117328974

<input type>으로

submit 이나

image 를 하는데..

자바스크립트로 check가 필요할때..

 

 

 

<script type="text/javascript">
 function check(){
  if(!f.id.value){
   alert("아이디를 입력하세요");
   f.id.focus();
   return false;
  }
  if(!f.pwd.value){
   alert("비밀번호를 입력하세요");
   f.pwd.focus();
   return false;
  }else{

    return true;
 }
</script>

 

 

<form name="f" action="./login_ok.jsp" method="post" onsubmit="return check();">

     <INPUT type="image" src="../img/bt_login.gif" width="40" height="21" BORDER="0" tabindex=3/>

</from>

즉 false가 오는 값을 받았을경우는 다음으로 넘어가지 않는다.