<script type="text/javascript">
function check_id_pw()
{
var iid = document.login.logid.value
var pass = document.login.pw.value
var b = document.login.logid.value.length
var c = document.login.pw.value.length
var len1 = 6
var len = 4
if(b>=len)
{
if(iid=="dddd111)
{
if(c>=len1)
{
if(pass=="11ddd")
{
alert("로그인되었습니다.");
if(document.login.saveid.value==true)
{
var name="name"
setCookie(name,document.login.logid.value,-1);
}
}
else
{
alert("패스워드가 잘못되었습니다");
}
}
else
{
alert("패스워드는 6자리 이상입니다.");
}
}
else
{
alert("아이디를 잘못 입력하셨습니다.");
}
}
else
{
alert("아이디는 4자리이상입니다.");
}
}
function numfil(e, decimal)
{
var key;
var keychar;
if (window.event)
{
key = window.event.keyCode;
}
else if (e)
{
key = e.which;
}
else
{
return true;
}
if ((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27)||(key==48)||(key==49)||(key==50)||(key==51)||(key==52)||(key==53)||(key==54)||(key==55)||(key==56)||(key==57) )
{
return true;
}
else
return false;
}
function chbox()
{
document.login.saveid.value= "1"
}
function setCookie(name,value,expires)
{
var nextday = new Date();
nextday.setDate(nextday.getDate() +1);
document.cookie=name+'='+escape(value)+((!expires)?'':(',expires='+nextday.toGMTString()));//+';path='+((!path)?'':path);
}
function getCookie(name)
{
name +="=";
var end
var cookies = document.cookie +";"
start = cookies.indexOf(name);
if(start !=-1)
{
end = cookies.indexOf(";",start);
return unescape(cookies.substring(start + name.length, end));
}
return
}
</script>
</HEAD>
<BODY>
<form name="login" method="post">
<input type="text" name="logid" value="" size="20" maxLength="10" style="ime-mode:disabled">
<input type="checkbox" name="saveid" value="" checked="" onClick="chbox()">ID저장
<br></br>
<input type="password" name="pw" size="20" maxLength ="12" onkeypress="numfil()" style="ime-mode:disabled">
<input type="button" name="log" value="로그인" onClick="check_id_pw()">
</form>
<script type="text/javascript">
var cook = getCookie(name);
if ((cook) !== ""|| cook!==null)
{
document.login.saveid.cheked="true"
var rname;
//쿠키값이 ,를만나면 그뒤는 출력X
rname = cook.split(",")
document.login.logid.value=rname[0];
}
</script>
</BODY>
</HTML>
살짝 야매로 짰다... 흠~~ 위에 코드를 보면 알겠지만 임의의 아이디 값과 패스워드를 저장해두었다....
저기에서 아뒤랑 패스워드가 맞으면 쿠키에 아뒤를 저장한다.. 그리고 새로 고침을 해도 아뒤가 뜨게 되는
형태이다... 정규식을 잘모를때 짠거라서... 좀 코드체크가 구리다.. 흠~!!! 키값자체를 비교하게 한거니...
많이 구린 느낌이다.... 역시나 2달전에는 나는 바보였군....ㅋㅋㅋㅋ
'프로그래밍 > HTML+CSS+JavaScript' 카테고리의 다른 글
| CSS ul의 li 형태로 탭을 만들때... (0) | 2009.10.25 |
|---|---|
| div안에 가운데쯤에 항목나타내기~ (0) | 2009.10.22 |
| 슬라이딩 윈도우 2 (0) | 2009.10.21 |
| CSS를 이용한 단순한 폼 (0) | 2009.10.21 |
| 슬라이딩 윈도우 (0) | 2009.10.21 |