게시글, 회원가입할때 주로 사용하는 null alert 매서드

 

 

로그인 회원가입
아이디(필수기입)
비밀번호(필수기입)
비밀번호 확인(필수기입)

 

 

 

 

 

 

 <form action="signupPro.jsp" method="post" name="inputForm" enctype="multipart/form-data" onsubmit="return checkField();">
	      <table>
			<tr>
				<td onclick="window.location='loginForm.jsp'"> 로그인 </td>
				<td onclick="window.location='signupForm.jsp'"> <b>회원가입<b></b> </td>
			</tr>	      
	         <tr>
	            <td>아이디(필수기입)</td>
	            <td><input type="text" name="u_id" /> </td>
	         </tr>
	         <tr>
	            <td>비밀번호(필수기입)</td>
	            <td><input type="password" name="u_pw" /></td>
	         </tr>
	         <tr>
	            <td>비밀번호 확인(필수기입)</td>
	            <td><input type="password" name="u_pwck" /></td>
	         </tr>
 			<tr>
	            <td colspan="2">
	               <input type="submit" value="회원가입" /> 
	               <input type="reset" value="재작성" /> 
	               <input type="button" value="취소" onclick="window.location='/team/banner/main.jsp'" />
	            </td>
	         </tr>
	      </table>
   </form>



	<script>
		function checkField(){
			let inputs = document.inputForm;
			if(!inputs.u_id.value){	// name속성이 id인 요소의 value가 없으면 true
				alert("아이디를 입력하세요.");
				return false;	// pro페이지로 이동 금지.
			}
			if(!inputs.u_pw.value){	
				alert("비밀번호를 입력하세요.");
				return false;
			}
			if(!inputs.u_pwch.value){
				alert("비밀번호 확인란을 입력하세요.");
				return false;
			}		
			if(inputs.u_pw.value != inputs.u_pwch.value){
				alert("비밀번호가 일치하지 않습니다.");
				return false;
			}
		}
	</script>

	  
</body>
	</html>

+ Recent posts