/**//**
* Check form
*/
function checkForm(vform)
{
for(var i=0;i<vform.elements.length;i++)
{
if(vform.elements[i].type=="text")
{
var checkResult=checkTextBox(vform.elements[i]);
var name=vform.elements[i].getAttribute("name");
if(checkResult)
{
document.getElementById(name+"Msg").className="feedbackHide";
}
else
{
document.getElementById(name+"Msg").className="feedbackShow";
vform.elements[i].focus();
return false;
}
}
}
return true;
}
/**//**
* Check text field in the form
*/
function checkTextBox(vTextBox)
{
var validChar=vTextBox.getAttribute("validChar");
var isRequired=vTextBox.getAttribute("isRequired");
var inputValue=vTextBox.value;
if(isRequired!="true" && inputValue.length<1)
{
return true;
}
else
{
var regexStr="^"+validChar+"$";
var regex=new RegExp(regexStr);
return regex.test(inputValue);
}
}
/**//**
* Remove Extra Char in textbox
*/
function removeExtraChar(vTextBox,event)
{
var maxlength=parseInt(vTextBox.getAttribute("maxlength"));
var inputValue=vTextBox.value;
if(inputValue.length>=maxlength)
{
event.keyCode=9;
}
}
<%
@ page contentType="text/html; charset=UTF-8" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>"我的事務(wù)備忘錄"用戶(hù)登錄頁(yè)面</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="web/js/ajax.js" type="text/javascript"></script>
<script src="web/js/formchecker.js" type="text/javascript"></script>
<link rel="stylesheet" rev="stylesheet" href="web/css/style.css"
type="text/css" />
</head>
<body>
<div id="branding">
<%
String msg = (String) request.getAttribute("Msg");
if (msg != null) {
out.print(msg);
}
%>
<!-- 外層表格,比內表格寬,以在左右留出一定空當 -->
<table style="border-right: 1px solid; border-top: 1px solid; border-left: 1px solid; border-bottom: 1px solid; boder_top: 0px" bordercolor="#236d78" cellspacing="0" cellpadding="0" width="530" align="center" border="0">
<tr bgcolor="#eaecf5" height="25">
<td colspan=3> <font face=webdings color=#ff8c00>8</font><b> 用戶(hù)登錄:</b></td>
</tr>
<tr bgcolor=#236d78 height=1><td></td></tr>
<tr bgcolor=#eaecf5 >
<td bgcolor=#ffffff>
<!-- 內置表格,居中,比外表格窄, -->
<form action="UserLogin" onsubmit="return checkForm(this);">
<table width=460 align=center border=0>
<tbody>
<tr>
<td width=70>用戶(hù)名:</td>
<td>
<input type="text"
name="userName"
validChar="[\u4E00-\u9FA5]{2,3}"
isRequired="true"
maxlength="8"
onkeydown="removeExtraChar(this,event)"
onfocus="this.style.backgroundColor='#e6e6e6'"
onblur="this.style.backgroundColor='#ffffff'"/>
<font color=red> (必填)</font>
<span id="userNameMsg" class="feedbackHide">用戶(hù)名必須輸入兩到三位漢字</span>
</td>
</tr>
<tr>
<td width=70>密碼:</td>
<td>
<input type="text"
name="userPswd"
validChar="\w+"
isRequired="true"
maxlength="8"
onkeydown="removeExtraChar(this,event)"
onfocus="this.style.backgroundColor='#e6e6e6'"
onblur="this.style.backgroundColor='#ffffff'"/>
<font color=red> (必填)</font>
<span id="userPswdMsg" class="feedbackHide">密碼必須輸入英語(yǔ)或數字</span>
</td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="登錄"/></td>
</tr>
<tr>
<td colspan="2" align="center">如果沒(méi)有用戶(hù)請點(diǎn)擊這里<a href='ShowPage?page=register'>注冊</a></td>
</tr>
</tbody>
</table>
</form>
<!-- 內置表格結束-->
</td>
</tr>
</table>
<!-- 外層表格結束 -->
<div>
</body>
</html>

聯(lián)系客服