2013년 11월 17일 일요일

로그인에 마우스 클릭하면 아이디 비밀번호 없어졌다가 다시 나타나기

Insert title here
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script>
function idFocus(){
 if(document.getElementById('id').value == '아이디')
  document.getElementById('id').value = '';
}
function idBlur(){
 if(document.getElementById('id').value == '')
  document.getElementById('id').value = '아이디';
}
function pwFocus(){
 if(document.getElementById('password').value == '비밀번호') {
  var original = document.getElementById('password');
  var copy = original.cloneNode(false);
  copy.type = 'password';
  copy.value = '';
  original.parentNode.replaceChild(copy, original);
  copy.focus();
  copy.select();
 }
}
function pwBlur(){
 if(document.getElementById('password').value == '') {
  var original = document.getElementById('password');
  var copy = original.cloneNode(false);
  copy.type = 'text';
  copy.value = '비밀번호';
  original.parentNode.replaceChild(copy, original);
 }
}
</script>
</head>
<body>
<table>
<tr>
<td>
<form method=post>
<input type=text value="아이디" name=id id=id onfocus=idFocus() onblur=idBlur()>
<input type=text value="비밀번호" name=password id=password onfocus=pwFocus() onblur=pwBlur()>
<input type=submit value="로그인">
</form>
</td>
</tr>
</table>
</body>
</html>

댓글 없음:

댓글 쓰기