<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Title</title>
<script src="https://code.jquery.com/jquery-3.7.0.min.js"></script>
<style>
</style>
</head>
<body>
<form action="" id = "loginform">
<div>아이디
<label >
<input type="text" id = "userid" name = "userid">
</label></div>
<div>비밀번호
<label >
<input type="password" id = "userpw" name = "userpw">
</label></div>
<div>비밀번호확인
<label >
<input type="password" id = "userpwchk" name = "userpw">
</label></div>
<input type="submit">
</form>
</body>
<script>
$("#loginform").on("submit",(e)=>{
const userid = $("#userid").val();
const userpw = $("#userpw").val();
const userpwchk = $("#userpwchk").val();
console.log(userid);
console.log(userpw);
console.log(userpwchk);
if(userid==='aaa'){
e.preventDefault();
alert('aaa는 사용할 수 없는 아이디입니다.');
return;
}
if(!(userpw===userpwchk)){
e.preventDefault();
alert("비밀번호와 비밀번호확인의 값이 서로 다릅니다.")
return;
}
// $("#loginform").trigger("submit");
//$("#loginform").submit();
})
</script>
</html>
댓글 영역