當前位置:名人名言大全網 - 短信平臺 - 用jsp實現壹個簡單的登錄界面,主要是驗證碼

用jsp實現壹個簡單的登錄界面,主要是驗證碼

<html>

<head>

<title>簡單頁面</title>

<script>

function yzm(){

var Num="";

for(var i=0;i<4;i++)

{

Num+=Math.floor(Math.random()*10);

}

document.getElementById("yzphoto").value=Num;

document.getElementById("yzm").value=Num;

}

function userLogin(){

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

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

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

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

if(userName != "jq"){

alert("用戶名錯誤");

}else if(password != "123"){

alert("密碼錯誤");

}else if(yztext != yzm){

alert("驗證碼錯誤");

}else{

alert("登陸成功");

}

location.reload();

}

</script>

</head>

<body onLoad="yzm()">

<div style="width:100%;text-align:center">

<h1>用戶登錄</h1>

<table>

<tr>

<td>用戶名:</td>

<td><input id="userName" type="text" value=""/></td>

</tr>

<tr>

<td>密碼:</td>

<td><input id="password" type="password" value=""/></td>

<tr>

<tr><td>

驗證碼:

</td>

<td><input id="yztext" type="text" value=""/><input style="width:50px;background-

color:red;color:blue" type="text" id="yzphoto" value=""/><input type="hidden" id="yzm"

value=""></td></tr>

<tr>

<td colspan="2" align="center"><input onclick="userLogin()" type="button" value="登陸"/></td>

</tr>

</table>

</div>

</body>

</html>