該函數接收
expireHours 為
<script language=
<!
function addCookie(name
var cookieString=name+
//判斷是否設置過期時間
if(expireHours>
var date=new Date();
date
cookieString=cookieString+
}
okie=cookieString;
}
//
</script>
該函數返回名稱為 name 的 cookie 值
<script language=
<!
function getCookie(name){
var strCookie=okie;
var arrCookie=strCookie
for(var i=
var arr=arrCookie[i]
if(arr[
}
return
}
//
</script>
該函數可以刪除指定名稱的 cookie
<script language=
<!
function deleteCookie(name){
var date=new Date();
date
okie=name+
}
//
</script>
<!DOCTYPE html PUBLIC
<html xmlns=
<head>
<meta http
<title>Javascript進行表單驗證</title>
<script type=
function jc(){
var a = document
if (a ==
alert(
return false;
}
var b = document
if (b
alert(
return false;
}
return true;
}
</script>
</head>
<body>
<form action=
<label>用戶名
<input type=
</label>
<label>密碼
<input type=
</label>
<input type=
</form>
</body>
</html>
From:http://tw.wingwit.com/Article/program/Java/hx/201311/26297.html