memberform.html

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Sign Up</title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="http://dmaps.daum.net/map_js_init/postcode.v2.js"></script>
<script>
	function openDaumPostcode() {
		new daum.Postcode({
			oncomplete : function(data) {
				document.getElementById('post').value = data.zonecode;
				document.getElementById('address').value = data.address;				
			}
		}).open();
	}
</script>

<script src="member.js"></script>

</head>
<body>

<form method="post" action="member.jsp">
<table border=1 width=600 align=center>
	<caption>Sign Up</caption>
	<tr><th>ID</th>
		<td><input type=text autofocus="autofocus" id="id" name="id">
			<input type="button" value="IDcheck" id="idcheck">
		</td>
	</tr>
	<tr><th>Password</th>
		<td><input type=password id="passwd" name="passwd"></td>
	</tr>
	<tr><th>Name</th>
		<td><input type=text id="name" name="name"></td>
	</tr>
	<tr><th>ID No.</th>
		<td><input type=text size=6 maxlength="6" id="jumin1" name="jumin1">-
		    <input type=text size=7 maxlength="7" id="jumin2" name="jumin2">
		</td>
	</tr>
	<tr><th>EMail</th>
		<td><input type=text size=10 id="mailid" name="mailid">@
			<input type=text size=10 id="domain" name="domain">
			<select id="email">
				<option value="">Email</option>
				<option value="naver.com">Naver</option>
				<option value="daum.net">Daum</option>
				<option value="nate.com">Nate</option>
				<option value="gmail.com">Google</option>
			</select>
		</td>
	</tr>
	<tr><th>Telephone</th>
		<td><input type=text size=4 maxlength="4" id="tel1" name="tel1">-
			<input type=text size=4 maxlength="4" id="tel2" name="tel2">-
			<input type=text size=4 maxlength="4" id="tel3" name="tel3">
		</td>
	</tr>
	<tr><th>Mobile</th>
		<td><select id="phone1" name="phone1">
				<option value="">Select</option>
				<option value="010">010</option>
				<option value="011">011</option>
				<option value="016">016</option>
				<option value="018">018</option>
				<option value="019">019</option>
			</select>-
			<input type=text size=4 maxlength="4" id="phone2" name="phone2">-
			<input type=text size=4 maxlength="4" id="phone3" name="phone3">
		</td>
	</tr>
	<tr><th>Postcode</th>
		<td><input type=text size=5 maxlength="5" id="post" name="post">
			<input type="button" value="Search" onClick="openDaumPostcode()">
		</td>
	</tr>
	<tr><th>Address</th>
		<td><input type=text size=70 id="address" name="address"></td>
	</tr>
	<tr><th>Sex</th>
		<td><input type=radio id="male" name="gender" value="Male">Male
			<input type=radio id="female" name="gender" value="Female">Female
		</td>
	</tr>
	<tr><th>Hobby</th>
		<td><input type=checkbox id="h1" name="hobby" value="Studying">Studying
			<input type=checkbox id="h2" name="hobby" value="Playing games">Playing games
			<input type=checkbox id="h3" name="hobby" value="Hiking">Hiking
			<input type=checkbox id="h4" name="hobby" value="Fishing">Fishing
			<input type=checkbox id="h5" name="hobby" value="Shopping">Shopping
		</td>
	</tr>
	<tr><th>About me</th>
		<td><textarea rows="5" cols="50" id="intro" name="intro"
			  placeholder="Please write up to 100 characters."></textarea></td>
	</tr>
	<tr><td colspan=2 align=center>
			<input type=submit value="Join">
			<input type=reset value="Cancel">
		</td>
	</tr>
</table>
</form>



</body>
</html>

member.js

$(document).ready(function(){
	
		// IDCheck
		$("#idcheck").click(function(){
			if($("#id").val()==""){
				alert("Insert your ID.");
				$("#id").focus();
				return false;
			}else{
				var ref="idcheck.jsp?id="+$("#id").val();
				window.open(ref,"idcheck","width=250, height=150")
			}
		});	
		
		// Focus
		$("#jumin1").keyup(function(){
			
			if($("#jumin1").val().length == 6)
				$("#jumin2").focus();
		});
		
		
		// Domain
		$("#email").change(function(){
			if($("#email").val() == ""){		
				$("#domain").attr("readOnly", false);		
				$("#domain").val("").focus();
			}else{								
				$("#domain").val($("#email").val());
				$("#domain").attr("readOnly", "readOnly");
			}			
		});			
		
		// Validation Check
		$("form").submit(function(){
			
			if($("#id").val() == ""){
				alert("Insert your ID.");
				$("#id").focus();
				return false;
			}
			if($("#passwd").val() == ""){
				alert("Insert your password.");
				$("#passwd").focus();
				return false;
			}
			if($("#name").val() == ""){
				alert("Insert your name.");
				$("#name").focus();
				return false;
			}
			if($("#jumin1").val() == ""){
				alert("Insert your ID number1.");
				$("#jumin1").focus();
				return false;
			}
			if($("#jumin1").val().length != 6){
				alert("Insert your ID number1.");
				$("#jumin1").val("").focus();
				return false;
			}
			// isNaN() 
			if(isNaN($("#jumin1").val())){
				alert("Insert numbers only.");
				$("#jumin1").val("").focus();
				return false;
			}
			if($("#jumin2").val() == ""){
				alert("Insert your ID number2.");
				$("#jumin2").focus();
				return false;
			}
			if($("#jumin2").val().length != 7){
				alert("Insert your ID number1.");
				$("#jumin2").val("").focus();
				return false;
			}
			// isNaN() 
			if(isNaN($("#jumin2").val())){
				alert("Insert numbers only.");
				$("#jumin2").val("").focus();
				return false;
			}
			if($("#mailid").val() == ""){
				alert("Insert your email address.");
				$("#mailid").focus();
				return false;
			}
			if($("#domain").val() == ""){
				alert("Insert the domain of your email.");
				$("#domain").focus();
				return false;
			}
			if($("#tel1").val() == ""){
				alert("Insert your tel1.");
				$("#tel1").focus();
				return false;
			}
			if(isNaN($("#tel1").val())){
				alert("Insert numbers only.");
				$("#tel1").val("").focus();
				return false;
			}
			if($("#tel2").val() == ""){
				alert("Insert your tel2.");
				$("#tel2").focus();
				return false;
			}
			if(isNaN($("#tel2").val())){
				alert("Insert numbers only.");
				$("#tel2").val("").focus();
				return false;
			}
			if($("#tel3").val() == ""){
				alert("Insert your tel3.");
				$("#tel3").focus();
				return false;
			}
			if(isNaN($("#tel3").val())){
				alert("Insert numbers only.");
				$("#tel3").val("").focus();
				return false;
			}
			if($("#phone1").val() == ""){
				alert("Select your mobile number1.");
				return false;
			}
			if($("#phone2").val() == ""){
				alert("Insert your mobile number2.");
				$("#phone2").focus();
				return false;
			}
			if(isNaN($("#phone2").val())){
				alert("Insert numbers only.");
				$("#phone2").val("").focus();
				return false;
			}
			if($("#phone3").val() == ""){
				alert("Insert your mobile number3.");
				$("#phone3").focus();
				return false;
			}
			if(isNaN($("#phone3").val())){
				alert("Insert numbers only.");
				$("#phone3").val("").focus();
				return false;
			}
			if($("#post").val() == ""){
				alert("Insert your postcode.");
				$("#post").focus();
				return false;
			}
			if($("#address").val() == ""){
				alert("Insert your address.");
				$("#address").focus();
				return false;
			}
			if($("#male").is(":checked") == false &&
			   $("#female").is(":checked") == false ){
				alert("Secelte your sex.")
				return false;
			}
			
			if($("input:checkbox[name='hobby']:checked").length < 2){
				alert("Select more than one hobby.")
				return false;
			}
			
			if($("#intro").val() == ""){
				alert("Write About me section.");
				$("#intro").focus();
				return false;
			}
			
			if($("#intro").val().length > 100){
				alert("About me section has to be up to 200 characters.");
				$("#intro").focus();
				return false;
			}
			
		});		
		
	});

member.jsp

<%@ page language="java" contentType="text/html; charset=EUC-KR"
    pageEncoding="EUC-KR"%>
<%
request.setCharacterEncoding("utf-8");

String id = request.getParameter("id");
String passwd = request.getParameter("passwd");
String name = request.getParameter("name");
String jumin1 = request.getParameter("jumin1");
String jumin2 = request.getParameter("jumin2");
String mailid = request.getParameter("mailid");
String domain = request.getParameter("domain");
String tel1 = request.getParameter("tel1");
String tel2 = request.getParameter("tel2");
String tel3 = request.getParameter("tel3");
String phone1 = request.getParameter("phone1");
String phone2 = request.getParameter("phone2");
String phone3 = request.getParameter("phone3");
String post = request.getParameter("post");
String address = request.getParameter("address");
String gender = request.getParameter("gender");

String[] hobby = request.getParameterValues("hobby");
String h = ""; 
for(String hy : hobby)
	h += hy + "-";

String intro = request.getParameter("intro");
String introduce = request.getParameter("intro").replace("\n", "<br>");

%>

ID : <%=id%> <br>
Password : <%=passwd%> <br>
Name : <%=name%> <br>
ID No. : <%=jumin1%>-<%=jumin2%> <br>
Email : <%=mailid%>@<%=domain%> <br>
Telephone : <%=tel1%>-<%=tel2%>-<%=tel3%> <br>
Mobile : <%=phone1%>-<%=phone2%>-<%=phone3%> <br>
Postcode : <%=post%> <br>
Address : <%=address%> <br>
Sex : <%=gender %> <br>
Hobby : <%=h %> <br>
About me1 : <pre><%=intro%></pre> <br>
About me2 : <br>
<%=introduce%> <br>
Postcode : <%=post%> <br>
ID : <%=id%> <br>

idcheck.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>

 ID : <%=request.getParameter("id") %>

boardform.html

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Bulletin Board</title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="board.js"></script>

</head>
<body>

<form method="post" action="board.jsp">
<table border=1 width=600 align=center>
	<caption>Bulletin Board</caption>
	<tr><th>Writer</th>  <!-- th : align center , bold  -->
		<td><input type=text size=30 id="writer" name="writer" 
							         placeholder="Writer"></td>
	</tr>
	<tr><th>Password</th>
		<td><input type=password size=30 id="passwd" name="passwd" placeholder="2~8 chracters"></td>
	</tr>
	<tr><th>Title</th>
		<td><input type=text size=60 id="subject" name="subject"></td>
	</tr>
	<tr><th>Content</th>
		<td><textarea rows="5" cols="50" id="content" name="content" placeholder="Write up to 200 characters."></textarea></td>
	</tr>
	<tr><th>Attach File</th>
		<td><input type=file></td>
	</tr>
	<tr><td colspan=2 align=center>
			<input type=submit value="Post">	 
			<input type=reset value="Cancel">     
		</td>
	</tr>
</table>
</form>

</body>
</html>

board.js

$(function(){
		$("form").submit(function(){
			if($.trim($("#writer").val()) == ""){
				alert("Insert writer name.");
				$("#writer").focus();
				return false;
			}
			if($.trim($("#passwd").val()) == ""){
				alert("Insert password.");
				$("#passwd").focus();
				return false;
			}
			if($("#passwd").val().length <2 || 
			   $("#passwd").val().length >8	){
				alert("Password has to be 2 ~ 8 characters.");
				$("#passwd").val("").focus();
				return false;
			}
			if($.trim($("#subject").val()) == ""){
				alert("Insert title.");
				$("#subject").focus();
				return false;
			}
			if($.trim($("#content").val()) == ""){
				alert("Insert content");
				$("#content").focus();
				return false;
			}
			if($.trim($("#content").val()).length > 200){
				alert("Content has to be up to 200 characters.");
				$("#content").focus();
				return false;
			}
		});		
	});

 

board.jsp(Option1)

<%@ page language="java" contentType="text/html; charset=EUC-KR"
    pageEncoding="EUC-KR"%>
<%
request.setCharacterEncoding("utf-8");

String writer = request.getParameter("writer");
String passwd = request.getParameter("passwd");
String subject = request.getParameter("subject");
String content = request.getParameter("content");
%>

Writer : <%=writer%> <br>
Password : <%=passwd%> <br>
Subject : <%=subject%> <br>
Content : <pre><%=content%></pre> <br>

The <pre></pre> tag helps to display the text exactly as written in the HTML source code.

board.jsp(Option2)

<%@ page language="java" contentType="text/html; charset=EUC-KR"
    pageEncoding="EUC-KR"%>
<%
request.setCharacterEncoding("utf-8");

String writer = request.getParameter("writer");
String passwd = request.getParameter("passwd");
String subject = request.getParameter("subject");
String content = request.getParameter("content");

String contents = 
	request.getParameter("content").replace("\n","<br>");
// <br> will be replaced instead of "\n"
%>

Writer : <%=writer%> <br>
Password : <%=passwd%> <br>
Subject : <%=subject%> <br>
Content1 : <pre><%=content%></pre> <br>
Content2 : <%=contents%>

'Codes & Projects' 카테고리의 다른 글

JSP) Log in / Shopping cart  (0) 2022.08.29
HTML / Javascript / JSP ) Sign up Form2  (0) 2022.08.28
Javascript/ JSP/ HTML ) Log in form  (0) 2022.08.27
Java) Finding Maximum value  (0) 2022.08.25
Java) Math.random()  (0) 2022.08.25

<HTML>

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Log in</title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
	/* $(document).ready(function(){
	$("form").submit(function(){
		if($.trim($("#id").val()) == ""){
			alert("Insert your ID.");
			$("#id").focus();
			return false;
		}			
		if($.trim($("#passwd").val()) == ""){
			alert("Insert your password.");
			$("#passwd").focus();
			return false;
		}			
	});		
	});	  */
</script>

<script src="login.js"></script>

</head>
<body>

	<form method="post" action="login.jsp">
		<table border=1 width=350 align=center>
			<caption>Log in</caption>
			<tr>
				<th>ID</th>
				<td><input type=text size=30 autofocus="autofocus" id="id"
					name="id"></td>
			</tr>
			<tr>
				<th>Password</th>
				<td><input type=password size=30 id="passwd" name="passwd"></td>
			</tr>
			<tr>
				<td colspan=2 align=center><input type=submit value="Log in">
					<input type=reset value="Cancel"></td>
			</tr>
		</table>
	</form>

</body>
</html>

<Javascript>

$(document).ready(function(){
		$("form").submit(function(){
			if($.trim($("#id").val()) == ""){
				alert("Insert your ID.");
				$("#id").focus();
				return false;
			}			
			if($.trim($("#passwd").val()) == ""){
				alert("Insert your password.");
				$("#passwd").focus();
				return false;
			}			
		});		
});

<JSP>

<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>

<%
	request.setCharacterEncoding("utf-8");

String id = request.getParameter("id");
String passwd = request.getParameter("passwd");
%>

ID :
<%=id%>
<br>
Password :
<%=passwd%>
<br>

'Codes & Projects' 카테고리의 다른 글

HTML / Javascript / JSP ) Sign up Form2  (0) 2022.08.28
HTML / Javascript /JSP ) Bulletin Board  (0) 2022.08.28
Java) Finding Maximum value  (0) 2022.08.25
Java) Math.random()  (0) 2022.08.25
jQuery/ JSP) Sign up Form  (0) 2022.08.24
public class Max {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int max = 0;
		int[] array = { 1, 5, 6, 8, 2 };

		for (int i = 0; i < array.length-1; i++) {
			if (array[i] > array[i + 1]) {
				max = array[i]; 
				if( max > array[i + 1]) {
					System.out.println(max);
				}
			}
		}

	}

}

'Codes & Projects' 카테고리의 다른 글

HTML / Javascript / JSP ) Sign up Form2  (0) 2022.08.28
HTML / Javascript /JSP ) Bulletin Board  (0) 2022.08.28
Javascript/ JSP/ HTML ) Log in form  (0) 2022.08.27
Java) Math.random()  (0) 2022.08.25
jQuery/ JSP) Sign up Form  (0) 2022.08.24

1. Dice

public class DiceRandom {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int a = 0;
		int b = 0;

		while (a + b != 5) {

			a = (int) (Math.random() * 6) + 1;
			b = (int) (Math.random() * 6) + 1;
			System.out.println(a + "," + b);
		}
	}

}

2. Lottery

import java.util.Random;

public class LotteryRandom {

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		// Making an Array
		Random ran = new Random();
		int[] Lottery = new int[6];

		// Picking random numbers
		int i;
		for (i = 0; i < 6; i++) {
			Lottery[i] = ran.nextInt(45) + 1;
			for (int j = 0; j < i; j++) {
				if (Lottery[i] == Lottery[j])
					i--;
				break; 
			}
			System.out.println("Lottery number : " + Lottery[i]);
		}

	}

}

 

'Codes & Projects' 카테고리의 다른 글

HTML / Javascript / JSP ) Sign up Form2  (0) 2022.08.28
HTML / Javascript /JSP ) Bulletin Board  (0) 2022.08.28
Javascript/ JSP/ HTML ) Log in form  (0) 2022.08.27
Java) Finding Maximum value  (0) 2022.08.25
jQuery/ JSP) Sign up Form  (0) 2022.08.24

Sign up Form

member_join.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Sign up</title>
<link rel="stylesheet" type="text/css" href="./css/admin.css" />
<link rel="stylesheet" type="text/css" href="./css/member.css" />
<script src="./js/jquery.js"></script>
<script src="./js/member.js"></script>
</head>
<body>
 <div id="join_wrap">
  <h2 class="join_title">Sign up</h2>
  <form name="f" method="post" action="member_join_ok.nhn"
  onsubmit="return check()" enctype="multipart/form-data">

   <table id="join_t">
    <tr>
     <th>ID</th>
     <td>
      <input name="join_id" id="join_id" size="14" class="input_box" />
      <input type="button" value="Check your ID" class="input_button"
      onclick="id_check()" />
      <div id="idcheck"></div>
     </td>
    </tr>
    
    <tr>
     <th>Password</th>
     <td>
      <input type="password" name="join_pwd1" id="join_pwd1" size="14"
      class="input_box" />
     </td>
    </tr>
    
    <tr>
     <th>Password</th>
     <td>
      <input type="password" name="join_pwd2" id="join_pwd2" size="14"
      class="input_box" />
     </td>
    </tr>
    
    <tr>
     <th>Name</th>
     <td>
      <input name="join_name" id="join_name" size="14" class="input_box" />
     </td>
    </tr>
    
    <tr>
     <th>Post code</th>
     <td>
      <input name="join_zip1" id="join_zip1" size="3" class="input_box"
      readonly onclick="post_search()" />-<input name="join_zip2"
      id="join_zip2" size="3" class="input_box" readonly 
      onclick="post_search()"/>
      <input type="button" value="Search" class="input_button"
      onclick="post_check()" />
     </td>
    </tr>
    
    <tr>
     <th>Address1</th>
     <td>
      <input name="join_addr1" id="join_addr1" size="50" class="input_box"
      readonly onclick="post_search()" />
     </td>
    </tr>
    
    <tr>
     <th>Address2</th>
     <td>
      <input name="join_addr2" id="join_addr2" size="37" class="input_box" />
     </td>
    </tr>
    
    <tr>
     <th>Telephone</th>
     <td>
     <%@ include file="../../jsp/include/tel_number.jsp"%>
      <select name="join_tel1" >      
      <c:forEach var="t" items="${tel}" begin="0" end="16">
      <option value="${t}">${t}</option>
      </c:forEach>        
      </select>-<input name="join_tel2" id="join_tel2" size="4"
      maxlength="4" class="input_box" />-<input  name="join_tel3"
      id="join_tel3" size="4" maxlength="4" class="input_box" />
     </td>
    </tr>
    
    <tr>
     <th>Mobile</th>
     <td>
     <%@ include file="../../jsp/include/phone_number.jsp" %>
     <select name="join_phone1">
      <c:forEach var="p" items="${phone}" begin="0" end="5">
       <option value="${p}">${p}</option>
      </c:forEach>
     </select>-<input name="join_phone2" id="join_phone2" size="4"
     maxlength="4" class="input_box" />-<input name="join_phone3"
     id="join_phone3" size="4" maxlength="4" class="input_box" />
     </td>
    </tr>
    
    <tr>
     <th>Email</th>
     <td>
      <input name="join_mailid" id="join_mailid" size="10" 
      class="input_box" />@<input name="join_maildomain" 
      id="join_maildomain" size="20" class="input_box" readonly />

      <select name="mail_list" onchange="domain_list()">
      <option value="">=Select=</option>
      <option value="daum.net">daum.net</option>
      <option value="nate.com">nate.com</option>
      <option value="naver.com">naver.com</option>
      <option value="hotmail.com">hotmail.com</option>
      <option value="gmail.com">gmail.com</option>
      <option value="0">Other</option>
     </select> 
     </td>
    </tr>
    
    <tr>
     <th>Profile picture</th>
     <td>
      <input type="file" name="join_profile" />
     </td>
    </tr>
   </table>
   
   <div id="join_menu">
    <input type="submit" value="Join" class="input_button" />
    <input type="reset" value="Cancel" class="input_button" 
    onclick="$('#join_id').focus();" />
   </div>
  </form>
 </div>
</body>
</html>

DAO

// DAO(Data Access Object)
package dao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.sql.DataSource;

public class MemberDAOImpl {
	
	Connection con=null;
	PreparedStatement pstmt=null;
	Statement stmt=null;
	ResultSet rs=null;
	DataSource ds=null;
	String sql=null; 	
	
	public int checkMemberId(String id){
		int re=-1;		// Available ID
		
		String driver = "oracle.jdbc.driver.OracleDriver";
		String url = "jdbc:oracle:thin:@localhost:1521:xe";
			
		try{
//		
//			con=ds.getConnection();
			
			Class.forName(driver);//JDBC Driver Loading
			con = DriverManager.getConnection(url, "scott", "tiger");
			
			sql="select join_code from join_member where join_id=?";

			pstmt=con.prepareStatement(sql);
			pstmt.setString(1,id);
			rs=pstmt.executeQuery();
			if(rs.next()){
				re=1;	 	// Occupied ID	
			}
			
		}catch(Exception e){
			e.printStackTrace();
		}finally{
			try{
				if(rs != null) rs.close();
				if(pstmt != null) pstmt.close();
				if(con != null) con.close();
			}catch(Exception e){
				e.printStackTrace();
			}
		}
		return re;
	}

 

member.js

 function check(){
	 if($.trim($("#join_id").val())==""){
		 alert("Insert your ID");
		 $("#join_id").val("").focus();
		 return false;
	 }
	 if($.trim($("#join_pwd1").val())==""){
		 alert("Insert your password");
		 $("#join_pwd1").val("").focus();
		 return false;
	 }
	 if($.trim($("#join_pwd2").val())==""){
		 alert("Insert your password(again)");
		 $("#join_pwd2").val("").focus();
		 return false;
	 }
	 if($.trim($("#join_pwd1").val()) != $.trim($("#join_pwd2").val())){

		 alert("Please double-check your password");
		 $("#join_pwd1").val("");
		 $("#join_pwd2").val("");
		 $("#join_pwd1").focus();
		 return false;
	 }
	 if($.trim($("#join_name").val())==""){
		 alert("Insert your name");
		 $("#join_name").val("").focus();
		 return false;
	 }
	 if($.trim($("#join_zip1").val())==""){
		 alert("Insert your post code1");
		 $("#join_zip1").val("").focus();
		 return false;
	 }
	 if($.trim($("#join_zip2").val())==""){
		 alert("Insert your post code2");
		 $("#join_zip2").val("").focus();
		 return false;
	 }
	 if($.trim($("#join_addr1").val())==""){
		 alert("Insert your address1");
		 $("#join_addr1").val("").focus();
		 return false;
	 }
	 if($.trim($("#join_addr2").val())==""){
		 alert("Insert your address2");
		 $("#join_addr2").val("").focus();
		 return false;
	 }
	 if($.trim($("#join_tel2").val())==""){
		 alert("Insert your telephone number");
		 $("#join_tel2").val("").focus();
		 return false;
	 }
	 if($.trim($("#join_tel3").val())==""){
		 alert("Insert your mobile number1");
		 $("#join_tel3").val("").focus();
		 return false;
	 }
	 if($.trim($("#join_phone2").val())==""){
		 alert("Insert your mobile number2");
		 $("#join_phone2").val("").focus();
		 return false;
	 }
	 if($.trim($("#join_phone3").val())==""){
		 alert("Insert your mobile number3");
		 $("#join_phone3").val("").focus();
		 return false;
	 }
	 if($.trim($("#join_mailid").val())==""){
		 alert("Insert your email ID");
		 $("#join_mailid").val("").focus();
		 return false;
	 }
	 if($.trim($("#join_maildomain").val())==""){
		 alert("Insert the domain of your email");
		 $("#join_maildomain").val("").focus();
		 return false;
	 }	 	 
 }
 
function post_search(){
	alert("Click the search button");
}

function post_check(){
	window.open("zipcode_find.nhn","Search",
			"width=420,height=200,scrollbars=yes");

}


function id_check(){
	$("#idcheck").hide();
	var memid=$("#join_id").val();	
	
	if($.trim($("#join_id").val()).length < 4){
		var newtext='<font color="red">Your ID must be at least 4 characters.</font>';
		$("#idcheck").text('');
		$("#idcheck").show();
		$("#idcheck").append(newtext);
		$("#join_id").val("").focus();
		return false;
	};
	if($.trim($("#join_id").val()).length >12){
		var newtext='<font color="red">Your ID must be less than 12 characters </font>';
		$("#idcheck").text('');
		$("#idcheck").show();
		$("#idcheck").append(newtext);
		$("#join_id").val("").focus();
		return false;
	};

	if(!(validate_userid(memid))){
		var newtext='<font color="red">Your ID must include lower case English and numbers</font>';
		$("#idcheck").text('');
		$("#idcheck").show();
		$("#idcheck").append(newtext);
		$("#join_id").val("").focus();
		return false;
	};
	

    $.ajax({
        type:"POST",
        url:"member_idcheck.jsp",    
        data: {"memid":memid},  
        success: function (data) {  
          alert(data);
      	  if(data==1){ 		
      		var newtext='<font color="red">The ID already exists</font>';
      			$("#idcheck").text('');
        		$("#idcheck").show();
        		$("#idcheck").append(newtext);
          		$("#join_id").val('').focus();
          		return false;
	     
      	  }else{			
      		var newtext='<font color="blue">Available ID</font>';
      		$("#idcheck").text('');
      		$("#idcheck").show();
      		$("#idcheck").append(newtext);
      		$("#join_pwd1").focus();
      	  }  	    	  
        }
        ,
    	 error:function(e){
    		  alert("data error"+e);
    	  }
      });	//$.ajax() end	
};

function validate_userid(memid){
  var pattern= new RegExp(/^[a-z0-9_]+$/);

  return pattern.test(memid); 
};
 
function domain_list() {
	 var num=f.mail_list.selectedIndex;
	if ( num == -1 ) {

	return true;
	 }
	 if(f.mail_list.value=="0")
	 {

	 f.join_maildomain.value="";

	 f.join_maildomain.readOnly=false;

	f.join_maildomain.focus();

	}
	 
	 else {
	 
	f.join_maildomain.value=f.mail_list.options[num].value;
	
	f.join_maildomain.readOnly=true;
	 }
 }

Output

'Codes & Projects' 카테고리의 다른 글

HTML / Javascript / JSP ) Sign up Form2  (0) 2022.08.28
HTML / Javascript /JSP ) Bulletin Board  (0) 2022.08.28
Javascript/ JSP/ HTML ) Log in form  (0) 2022.08.27
Java) Finding Maximum value  (0) 2022.08.25
Java) Math.random()  (0) 2022.08.25

+ Recent posts