対応状況 |
head部のソース
<head>
<script type="text/JavaScript">
<!--
// メンバー名の配列
theMemName = new Array();
theMemName[0] = "poko";
theMemName[1] = "peko";
theMemName[2] = "todo";
theMemName[3] = "tiger";
theMemName[4] = "bear";
MemCount = 5; // 総メンバー数
thePassWord = "member"; // パスワード
function check()
{
// 入力された値を取得
theName = document.loginForm.MemN.value;
theWord = document.loginForm.PassW.value;
for (i = 0; i < MemCount; i++) // メンバー名とパスワードを検証
{
if ( (theName == theMemName[i]) && (theWord == thePassWord) )
{
return true;
break;
}
}
return false;
}
function login()
{
// 関数check()がtrueならばメンバー専用のページへ
if (check()) liURL = "member.html"; else liURL = "err.html";
location.href = liURL;
}
//-->
</script>
</head>
<body>
<form name="loginForm" method="post" action="./">
メンバー名:<input type="text" name="MemN">
パスワード:<input type="password" name="PassW">
<input type="button" value="ログイン" onClick="login()">
</form>
</body>
check()
は、メンバー名とパスワードが合致した時のみtrueを返します。member.htmlとerr.htmlは適当に用意して下さい。
表示