Notice
Recent Posts
Recent Comments
Link
«   2024/07   »
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
Tags
more
Archives
Today
Total
관리 메뉴

WON.dev

chapter02 : input_check 본문

WEB.JS/09.FORM_JS

chapter02 : input_check

GAWON 2023. 5. 22. 09:29
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
	function goLogin(){
		
		var form = document.forms.myForm;
 		
		if(form.id.value == ""){
			alert("아이디는 반드시 입력해야합니다.");
			return false;
		}
		
		if(form.pw.value == "" || 
			form.pw.value.length < 8 || 
			form.pw.value.length > 16){
			
			alert("비밀번호는 반드시 8~16자 사이로 입력해야 합니다.");
			form.pw.value = "";	// 데이터 초기화
			form.pw.focus();
			
			return false;
		}

		return true;
	}
</script>
</head>
<body>
	<!-- onsubmit은 submit 버튼일 때 사용 -->
	<form action="#" name="myForm" onsubmit="return goLogin()">
		아이디 <input type="text" name="id"><br/>
		<label for="uPw">비밀번호</label>
		<input type="password" name="pw" id="uPw"><br/>
		<input type="submit" value="로그인"><!-- submit은 onclick 없이 작업 -->
	</form>
</body>
</html>

'WEB.JS > 09.FORM_JS' 카테고리의 다른 글

chapter01 : input_check  (0) 2023.05.22
chapter03 : input_check  (0) 2023.05.22
chapter04 : input_check  (0) 2023.05.22
chapter05_regExp  (0) 2023.05.22
chapter06 : join_정규식  (0) 2023.05.22