본문 바로가기

IT/수원스터디

2. JS(java script)


1.

<!doctype html>

<html>

 <head>

  <meta charset="UTF-8">

  <title>자바스크립트테스트</title>

 <script>

function test(){

alert('테스트입니다.');

}

 </script>

 

 </head>


 <body>

  

  <input type="button" value="test" onClick="javascript:test()">

<br>

<input type="text" value="Yes" name="id">

  

 </body>

</html>





2.

<!doctype html>

<html>

 <head>

  <meta charset="UTF-8">

  <title>자바스크립트테스트</title>

 <script>

function test(){

var name=frm.name.value;

alert(name);

var id=document.getElementById("id").value;

alert(id);


var name2=document.getElementsByName("name")[0].value;

alert(name2);

}

 </script>

 

 </head>


 <body>

  <form name="frm">


  <input type="button" value="test" onClick="javascript:test()">

<br>

<input type="text" value="Yes" name="name" id="id">

  </form>

 </body>

</html>




3.

<!DOCTYPE html>

<html>

<head>

<meta charset="EUC-KR">

<style>

body {

    background-color: #CCCCCC;

   

}


h1 {

    color: red;

    text-align: center;

}


p {

    font-family: "Times New Roman";

    font-size: 20px;

}

td{

    border-bottom: aqua;

}

</style>


<script>

function Join(){

var frm=document.joinform;


if(frm.email.value.length<1){

alert('email 을 입력해주세요.');

return ;

}

if(frm.pwd.value.length<1){

alert('pwd 를 입력해주세요.');

return ;

}

if(frm.pwd2.value.length<1){

alert('pwd2 을 입력해주세요.');

return ;

}

if(frm.pwd.value!=frm.pwd2.value){

alert('비밀번호가 일치 하지 않습니다.');

return ;

}

if(frm.name.value.length<1){

alert('name 을 입력해주세요.');

return ;

}

if(frm.pno.value.length<1){

alert('pno 을 입력해주세요.');

return ;

}

if(frm.address.value.length<1){

alert('address 을 입력해주세요.');

return ;

}

alert('성공');

frm.action="./join.html";

frm.method="post";

frm.submit();


}

</script>

</head>

<body>

<form name="joinform">

<table border=0 align=center>

<tr>

<td width="770" colspan="2" align=center><font size="8">join</font></td>

</tr>

<tr>

<td>

<table   align=center>

<tr>

<td width="120">E-mail</td>

<td width="520"><input type="text" name="email"  autocomplete ="off" ><font color=red>*</font></td>

</tr>

<tr>

<td width="120">password</td>

<td width="520"><input type="password" name="pwd" autocomplete ="off"><font color=red>*</font></td>

</tr>

<tr>

<td width="120">password</td>

<td width="520"><input type="password" name="pwd2" autocomplete ="off"><font color=red>*</font></td>

</tr>

<tr>

<td width="120">name</td>

<td width="520"><input type="text" name="name" autocomplete ="off"><font color=red>*</font></td>

</tr>

<tr>

<td width="120">P No</td>

<td width="520"><input type="text" name="pno" autocomplete ="off"><font color=red>*</font></td>

</tr>

<tr>

<td width="120">address</td>

<td width="520"><input type="text" name="address"  style="width: 510px;" autocomplete ="off"></td>

</tr>

<tr>

<td width="120">zip-code</td>

<td width="520"><input type="text" name="address_num1" style="width: 65px;"autocomplete ="off" >-

<input type="text" name="address_num2" style="width: 65px;" autocomplete ="off"></td>

</tr>

<tr>

<td colspan=2 align=center><input type="button"  value="Join" onclick="Join()"><input type="reset" value="reset"></td>

</tr>

</table>

</td>

</tr>

</table>

</form>

</body>

</html>




4.


<!doctype html>

<html>

 <head>

  <meta charset="UTF-8">

  <title>test</title>

 <script>

function checkid(){

var frm=document.joinform;

var regExp=/^([/\w/g\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})$/;

if(!regExp.test(frm.email.value)){

alert('올바른 email을 입력해주세요.');

frm.email.focus();

}

}


function domainCheck(){

var frm=document.joinform;

if(frm.domain.value==0){

                        frm.e_domain.value="";

frm.e_domain.disabled=false;

}else{

                        frm.e_domain.value=frm.domain.value;

frm.e_domain.disabled=true;

}

}

 </script>

 

 </head>

<body>

<form name="joinform">

<table border=0 align=center>

<tr>

<td width="770" colspan="2" align=center><font size="8">join</font></td>

</tr>

<tr>

<td>

<table   align=center>

<tr>

<td width="120">E-mail</td>

<td width="520"><input type="text" name="email"  autocomplete ="off" onblur="javascript:checkid()"><font color=red>*</font></td>

</tr>

<tr>

<td width="120">E-mail2</td>

<td width="520">

<input type="text" name="email"  autocomplete ="off">

<input type="text" name="e_domain" >

<select name="domain" onchange="domainCheck();">

<option value="0">직접입력</option>

<option value="naver.com">naver.com</option>

<option value="daum.net">daum.net</option>

<option value="nate.com">nate.com</option>

<select>

<font color=red>*</font></td>

</tr>

</table>

</td>

</tr>

</table>

</form>

</body>

</html>









'IT > 수원스터디' 카테고리의 다른 글

동적테이블, 체크박스 전체 체크, 버튼..value  (0) 2014.08.24
동적테이블등.. 과제 body 부분  (0) 2014.08.17
2-2. JS, opener로 값 보내기  (0) 2014.08.13
1. HTML  (0) 2014.07.10
0. 시작  (0) 2014.07.10