永发信息网

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

答案:3  悬赏:80  手机版
解决时间 2021-05-24 17:06

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

我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
谁跟我组队打赛尔号的三条龙
古人励志经典语录励志,古代有哪些明人说过一
川汇区周口巴拉巴拉地址在哪里啊
厦门千允服装公司怎么走
1993年农历8月11日出生看命运
知己的味道
龙头龟身是什么,龙头龟身是什么?
舞阳县漯河新潮家具城(北舞渡店)地址在哪,我
亲人出国工作的祝福语,出国留学祝福语
超越砂锅麻辣烫建校分店这个地址在什么地方,
汉阳区武汉77连锁酒店(汉阳店)这个地址怎么能
有什么可以赚钱的平台,现在网上有没有答题赚
山东枣庄这边的高中课本分别是什么出版社的?
玻璃钢风管漏油怎么处理?
爱情宝典的内容
推荐资讯
西安区牡丹江海艺文化传播有限公司在什么地方
音乐虫太原街店具体消费??
间接融资工具
《消失的海岸线》七微发表在哪一期的杂志上
为什么dnf打着打着无色放不来了,东西都用不
浉河区信阳美锐大药房(农专路)地址在什么地方
家具是深红色的 怎么刷墙啊
孩子在几岁的时候的教育最关键?
碧玉年华的诗词,关于描写青春年华的古诗
光明玻璃装饰行我想知道这个在什么地方
什么样的蜥蜴最好喂?
老公不回信息代表什么,女生回信息回 “嗯”“
正方形一边上任一点到这个正方形两条对角线的
阴历怎么看 ?