以下是我自己做的论证。。
在Tomcat和Weblogic下能够正常的论证:
<%@ page language="java" import="java.lang.*,java.util.*,project.Member,project.MemberImp" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Member Orders</title>
<link rel="stylesheet" type="text/css" href="/ADICTProject/css/body.css">
<script type='text/javascript'>
function validation(frm)
{
var isValid = true;
if(frm.realname.value.length == 0)
{
alert("Please Input Your Realname!");
isValid = false;
return isValid;
}
for (i = 0; i < frm.realname.value.length; i++)
{
// Check that current character is letter.
var c = frm.realname.value.charAt(i);
if (!(isLetter(c)||isWhitespace(c)))
{
alert("Realname only contains a-z, A-Z and Whitespace");
isValid = false;
return isValid;
}
}
if( !(frm.gender[0].checked || frm.gender[1].checked) )
{
alert("Please Choose Your Gender!");
isValid = false;
return isValid;
}
if( frm.contact.value.length != 8 )
{
alert("Length of Contact Number must be 8!");
isValid = false;
return isValid;
}
for( i = 0; i < 8; i++)
{
var c = frm.contact.value.charAt(i);
if( ! isDigit(c) )
{
alert("Contact Number Only Contains Digits!");
isValid = false;
return isValid;
}
}
if( frm.email.value.indexOf("@") == -1)
{
alert("Email shoud contains '@'");
isValid = false;
return isValid;
}
if(frm.address.value.length == 0)
{
alert("Please Input Your Address!");
isValid = false;
return isValid;
}
if(frm.zipcode.value.length == 0)
{
alert("Please Input The Zipcode!");
isValid = false;
return isValid;
}
for(i = 0; i < frm.zipcode.value.length; i++)
{
var c = frm.zipcode.value.charAt(i);
if(! isDigit(c))
{
alert("Zipcode only contains Digits!");
isValid = false;
return isValid;
}
}
return isValid;
}
function isLetter (c)
{
return ( ((c >= "a") && (c <= "z")) || ((c >= "A") && (c <= "Z")) );
}
function isDigit (c)
{
return ((c >= "0") && (c <= "9"));
}
function isWhitespace (c)
{
return ( c == " " );
}
</script>
</head>
<body>
<center>
<table border="0" width="768">
<tr> <!-- header -->
<td colspan="2">
<jsp:include page="/header.jsp" />
</td>
</tr>
<tr> <!-- menu & content -->
<td valign="top" > <!-- menu -->
<jsp:include page="/menu.jsp" />
</td>
<td> <!-- content -->
<table border="0"><form action="/ADICTProject/servlet/Update" method="POST" name="modification" οnsubmit="return validation(this);" >
<tr>
<%
if(session.getAttribute("USER") == null)
{
%>
<jsp:forward page="/error.jsp" />
<%
}
String path = request.getServletPath();
path = path.substring(0,path.indexOf("member/modify.jsp"));
String xml = application.getRealPath(path + "XMLData/members.xml");
MemberImp imp = new MemberImp();
Member member = imp.getMember(session.getAttribute("USER").toString(),xml);
%>
<td><input type="hidden" name="username" value="<%= member.getUsername()%>" />
<input type="hidden" name="password" value="<%= member.getPassword()%>" />
<input type="hidden" name="repassword" value="<%= member.getPassword() %>" />
</td>
</tr>
<tr>
<td> Realname: </td>
<td> <input type="text" name="realname" value="<%= member.getRealname() %>"></td>
<tr>
<td colspan="2" align="center" >
<input type="radio" name="gender" value="male">male
<input type="radio" name="gender" value="female">Female
</td>
<tr>
<td> Bith: </td>
<td>
<select name="day">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
</select>
<select name="month">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
</select>
<select name="year">
<option value="1970">1970</option>
<option value="1971">1971</option>
<option value="1972">1972</option>
<option value="1973">1973</option>
<option value="1974">1974</option>
<option value="1975">1975</option>
<option value="1976">1976</option>
<option value="1977">1977</option>
<option value="1978">1978</option>
<option value="1979">1979</option>
<option value="1980">1980</option>
<option value="1981">1981</option>
<option value="1982">1982</option>
<option value="1983">1983</option>
<option value="1984">1984</option>
<option value="1985">1985</option>
<option value="1986">1986</option>
</select>
</td>
</tr>
<tr>
<td> Contact: </td>
<td> <input type="text" name="contact" value="<%= member.getContact() %>"></td>
</tr>
<tr>
<td> Email: </td>
<td> <input type="text" name="email" value="<%= member.getEmail() %>"></td>
</tr>
<tr>
<td> Address: </td>
<td> <textarea name="address" rows="3"><%= member.getAddress() %></textarea> </td>
</tr>
<tr>
<td> Zipcode: </td>
<td> <input type="text" name="zipcode" value="<%= member.getZipcode() %>"></td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" value="Update" />
<input type="button" value="Canel" οnclick="goBack();" />
</td>
</tr>
</table>
</td>
</tr>
</tr>
<td colspan="2" ><!-- footer -->
<jsp:include page="/footer.jsp" />
</td>
</tr>
</table>
</center>
<script type='text/javascript'>
<%
StringTokenizer st = new StringTokenizer(member.getBirth(),"//");
String strDate = st.nextToken();
String strMonth = st.nextToken();
String strYear = st.nextToken();
String strGender = member.getGender();
if(strGender.equalsIgnoreCase("male"))
{
%>
document.modification.gender[0].checked = true;
<%
}
else
{
%>
document.modification.gender[1].checked = true;
<%
}
%>
document.modification.day.value = <%= strDate %>;
document.modification.month.value = <%= strMonth %>;
document.modification.year.value = <%= strYear %>;
function goBack()
{
history.go(-1);
}
</script>
</body>
</html>