<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns=" http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<body>
<SCRIPT language=javascript type=text/javascript>
<!--
var pwdReq1 = document.all ? document.all["pwdReq1"] : document.getElementById("pwdReq1");
pwdReq1.controltovalidate = "wPwd1a";
pwdReq1.errormessage = "請必輸入";
pwdReq1.display = "Dynamic";
pwdReq1.evaluationfunction = "RequiredFieldValidatorEvaluateIsValid";
pwdReq1.initialvalue = "";
var CompareValidator1 = document.all ? document.all["CompareValidator1"] : document.getElementById("CompareValidator1");
CompareValidator1.controltovalidate = "wPwd2a";
CompareValidator1.errormessage = "密碼確認不符";
CompareValidator1.display = "Dynamic";
CompareValidator1.evaluationfunction = "CompareValidatorEvaluateIsValid";
CompareValidator1.controltocompare = "wPwd1a";
CompareValidator1.controlhookup = "wPwd1a";
var pwdLength1 = document.all ? document.all["pwdLength1"] : document.getElementById("pwdLength1");
pwdLength1.controltovalidate = "wPwd1a";
pwdLength1.errormessage = "密碼必須使用(0-9,A-E)而且至少為 8 或至多 12 個字元";
pwdLength1.display = "Dynamic";
pwdLength1.evaluationfunction = "RegularExpressionValidatorEvaluateIsValid";
pwdLength1.validationexpression = "[a-e0-9]{8,12}";
var pwdReq2 = document.all ? document.all["pwdReq2"] : document.getElementById("pwdReq2");
pwdReq2.controltovalidate = "wPwd2a";
pwdReq2.errormessage = "請必輸入";
pwdReq2.display = "Dynamic";
pwdReq2.evaluationfunction = "RequiredFieldValidatorEvaluateIsValid";
pwdReq2.initialvalue = "";
var pwdLength2 = document.all ? document.all["pwdLength2"] : document.getElementById("pwdLength2");
pwdLength2.controltovalidate = "wPwd2a";
pwdLength2.errormessage = "密碼必須使用(0-9,A-E)而且至少為 8 或至多 12 個字元";
pwdLength2.display = "Dynamic";
pwdLength2.evaluationfunction = "RegularExpressionValidatorEvaluateIsValid";
pwdLength2.validationexpression = "[a-e0-9]{8,12}";
// -->
</SCRIPT>
</body>
</html>
在第一行加上
<%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
不然会乱码
你的页面里根本没有pwdReq1 这个对象,当然会错了,我猜你的这个pwdReq1应该是个textbox框之类的东西吧,但是你的html里面压根没有这个东西
这样就没错 缺少body里面的标签
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns=" http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<body>
<input id="pwdReq1"><!--缺少 id为pwdReq1 的DOM对象 下面几个也是同样-->
<input id="CompareValidator1">
<input id="pwdLength1">
<input id="pwdReq2">
<input id="pwdLength2">
<SCRIPT language=javascript type=text/javascript>
<!--
var pwdReq1 = document.all ? document.all["pwdReq1"] : document.getElementById("pwdReq1");
pwdReq1.controltovalidate = "wPwd1a";
pwdReq1.errormessage = "請必輸入";
pwdReq1.display = "Dynamic";
pwdReq1.evaluationfunction = "RequiredFieldValidatorEvaluateIsValid";
pwdReq1.initialvalue = "";
var CompareValidator1 = document.all ? document.all["CompareValidator1"] : document.getElementById("CompareValidator1");
CompareValidator1.controltovalidate = "wPwd2a";
CompareValidator1.errormessage = "密碼確認不符";
CompareValidator1.display = "Dynamic";
CompareValidator1.evaluationfunction = "CompareValidatorEvaluateIsValid";
CompareValidator1.controltocompare = "wPwd1a";
CompareValidator1.controlhookup = "wPwd1a";
var pwdLength1 = document.all ? document.all["pwdLength1"] : document.getElementById("pwdLength1");
pwdLength1.controltovalidate = "wPwd1a";
pwdLength1.errormessage = "密碼必須使用(0-9,A-E)而且至少為 8 或至多 12 個字元";
pwdLength1.display = "Dynamic";
pwdLength1.evaluationfunction = "RegularExpressionValidatorEvaluateIsValid";
pwdLength1.validationexpression = "[a-e0-9]{8,12}";
var pwdReq2 = document.all ? document.all["pwdReq2"] : document.getElementById("pwdReq2");
pwdReq2.controltovalidate = "wPwd2a";
pwdReq2.errormessage = "請必輸入";
pwdReq2.display = "Dynamic";
pwdReq2.evaluationfunction = "RequiredFieldValidatorEvaluateIsValid";
pwdReq2.initialvalue = "";
var pwdLength2 = document.all ? document.all["pwdLength2"] : document.getElementById("pwdLength2");
pwdLength2.controltovalidate = "wPwd2a";
pwdLength2.errormessage = "密碼必須使用(0-9,A-E)而且至少為 8 或至多 12 個字元";
pwdLength2.display = "Dynamic";
pwdLength2.evaluationfunction = "RegularExpressionValidatorEvaluateIsValid";
pwdLength2.validationexpression = "[a-e0-9]{8,12}";
// -->
</SCRIPT>
</body>
</html>