永发信息网

帮忙看看这个页面中的javascript代码出错

答案:3  悬赏:80  手机版
解决时间 2021-05-24 17:06
  • 提问者网友:沉默菋噵
  • 2021-05-24 02:38

<!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>

最佳答案
  • 五星知识达人网友:像个废品
  • 2021-05-24 02:58

在第一行加上


<%@ page language="java" import="java.util.*" pageEncoding="GBK"%>


不然会乱码

全部回答
  • 1楼网友:猎心人
  • 2021-05-24 04:23

你的页面里根本没有pwdReq1 这个对象,当然会错了,我猜你的这个pwdReq1应该是个textbox框之类的东西吧,但是你的html里面压根没有这个东西

  • 2楼网友:鸽屿
  • 2021-05-24 03:19

这样就没错 缺少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>

我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯