jsp中用javascript判断两次输入内容是否一致,为什么不弹出对话框啊?代码如下
代码在这里——http://hi.baidu.com/spg198/blog/item/919aea0f9ed5c0df7bcbe191.html...
代码在这里——http://hi.baidu.com/spg198/blog/item/919aea0f9ed5c0df7bcbe191.html
展开
6个回答
展开全部
<%@ page language="java" contentType="text/html; charset=GB18030"
pageEncoding="GB18030"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB18030">
<LINK media=screen href="./css/style2.css" type=text/css
rel=stylesheet>
<title>新用户注册</title>
<script type="text/javascript" language="javaScript">
function check() {
var pwd1 = Document.form1.pwd1.value;
var pwd2 = Document.form1.pwd2.value;
if(pwd1!=pwd2){
alter("两次输入密码不一致,请重新输入!");
return false;
}else{
return true;
}
}
</script>
</head>
<body bgcolor="#CCFFCC">
<div class="container">
<div class="header"><a><img src="./img/head.JPG" alt="在此处插入徽标" name="Insert_logo" width="180" height="90" id="Insert_logo" style="background: #C6D580; display:block;" /></a>
<!-- end .header --></div>
<div class="content">
<form id="form1" name="form1" method="post" action="regist.do" onsubmit="return check()">
<table width="700" height="312" border="1" align="center" cellspacing="0">
<tr align="left" valign="middle">
<td width="242" align="right">User Name:</td>
<td width="448"><input type="text" name="uname" id="uname" style="width:200px;height:20px"/>
<font color="red">*</font></td>
</tr>
<tr>
<td align="right">Student ID:</td>
<td align="left" valign="middle"><input type="text" name="uno" id="uno" style="width:200px;height:20px"/>
<font color="red"> *</font></td>
</tr>
<tr>
<td align="right">Sex:</td>
<td align="left" valign="middle"><select name="sex" id="sex">
<option value="1">boy</option>
<option value="2">girl</option>
</select>
</td>
</tr>
<tr>
<td align="right">Password:</td>
<td align="left" valign="middle"><input type="password" name="pwd1" id="pwd" style="width:200px;height:20px"/>
<font color="red"> *</font></td>
</tr>
<tr>
<td align="right">Confirm Password:</td>
<td align="left" valign="middle"><input type="password" name="pwd2" id="pwd2" style="width:200px;height:20px"/>
<font color="red"> *</font></td>
</tr>
<tr>
<td align="right">Phone:</td>
<td align="left" valign="middle"><input type="text" name="phone" id="utelno" style="width:200px;height:20px"/>
<font color="red"> *</font></td>
</tr>
<tr>
<td align="right">Email:</td>
<td align="left" valign="middle"><input type="text" name="email" id="email" style="width:200px;height:20px"/>
<font color="red"> *</font></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="Submit" />
<input name="重置" type="reset" value="Re-fill" /></td>
</tr>
</table>
</form>
<h1> </h1>
<!-- end .content --></div>
<div class="footer">
<p> </p>
<!-- end .footer --></div>
<!-- end .container --></div>
</body>
</html>
您的Document在哪呢?
pageEncoding="GB18030"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB18030">
<LINK media=screen href="./css/style2.css" type=text/css
rel=stylesheet>
<title>新用户注册</title>
<script type="text/javascript" language="javaScript">
function check() {
var pwd1 = Document.form1.pwd1.value;
var pwd2 = Document.form1.pwd2.value;
if(pwd1!=pwd2){
alter("两次输入密码不一致,请重新输入!");
return false;
}else{
return true;
}
}
</script>
</head>
<body bgcolor="#CCFFCC">
<div class="container">
<div class="header"><a><img src="./img/head.JPG" alt="在此处插入徽标" name="Insert_logo" width="180" height="90" id="Insert_logo" style="background: #C6D580; display:block;" /></a>
<!-- end .header --></div>
<div class="content">
<form id="form1" name="form1" method="post" action="regist.do" onsubmit="return check()">
<table width="700" height="312" border="1" align="center" cellspacing="0">
<tr align="left" valign="middle">
<td width="242" align="right">User Name:</td>
<td width="448"><input type="text" name="uname" id="uname" style="width:200px;height:20px"/>
<font color="red">*</font></td>
</tr>
<tr>
<td align="right">Student ID:</td>
<td align="left" valign="middle"><input type="text" name="uno" id="uno" style="width:200px;height:20px"/>
<font color="red"> *</font></td>
</tr>
<tr>
<td align="right">Sex:</td>
<td align="left" valign="middle"><select name="sex" id="sex">
<option value="1">boy</option>
<option value="2">girl</option>
</select>
</td>
</tr>
<tr>
<td align="right">Password:</td>
<td align="left" valign="middle"><input type="password" name="pwd1" id="pwd" style="width:200px;height:20px"/>
<font color="red"> *</font></td>
</tr>
<tr>
<td align="right">Confirm Password:</td>
<td align="left" valign="middle"><input type="password" name="pwd2" id="pwd2" style="width:200px;height:20px"/>
<font color="red"> *</font></td>
</tr>
<tr>
<td align="right">Phone:</td>
<td align="left" valign="middle"><input type="text" name="phone" id="utelno" style="width:200px;height:20px"/>
<font color="red"> *</font></td>
</tr>
<tr>
<td align="right">Email:</td>
<td align="left" valign="middle"><input type="text" name="email" id="email" style="width:200px;height:20px"/>
<font color="red"> *</font></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="Submit" />
<input name="重置" type="reset" value="Re-fill" /></td>
</tr>
</table>
</form>
<h1> </h1>
<!-- end .content --></div>
<div class="footer">
<p> </p>
<!-- end .footer --></div>
<!-- end .container --></div>
</body>
</html>
您的Document在哪呢?
展开全部
var pwd1 = Document.form1.pwd1.value;
var pwd2 = Document.form1.pwd2.value;
这里有错误,你要么
var pwd1 = form1.pwd1.value;
var pwd2 = form1.pwd2.value;
要么
var pwd1 = document.getElementById("pwd").value;
var pwd2 = document.getElementById("pwd2").value;
另外
alter 也写错了,应该是 alert("两次输入密码不一致,请重新输入!");
var pwd2 = Document.form1.pwd2.value;
这里有错误,你要么
var pwd1 = form1.pwd1.value;
var pwd2 = form1.pwd2.value;
要么
var pwd1 = document.getElementById("pwd").value;
var pwd2 = document.getElementById("pwd2").value;
另外
alter 也写错了,应该是 alert("两次输入密码不一致,请重新输入!");
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<script type="text/javascript" language="javaScript">
function check() {
var pwd1 = document.form1.pwd1.value;
var pwd2 = document.form1.pwd2.value;
if(pwd1==pwd2){
return true;
}else{
alert("两次输入密码不一致,请重新输入!");
return false;
}
}
function check() {
var pwd1 = document.form1.pwd1.value;
var pwd2 = document.form1.pwd2.value;
if(pwd1==pwd2){
return true;
}else{
alert("两次输入密码不一致,请重新输入!");
return false;
}
}
参考资料: sername
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
var pwd1 = document.form1.pwd1.value;
var pwd2 = document.form1.pwd2.value;
if(pwd1!=pwd2){
alert("两次输入密码不一致,请重新输入!");
return false;
}else{
return true;
}
大哥。。。你if里面的 alert 拼写错误。。你写成alter了
还有document小写
var pwd2 = document.form1.pwd2.value;
if(pwd1!=pwd2){
alert("两次输入密码不一致,请重新输入!");
return false;
}else{
return true;
}
大哥。。。你if里面的 alert 拼写错误。。你写成alter了
还有document小写
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你讲设置第一个密码处,即pwd1的id改为“pwd1”,然后javascript处写如下代码
var pwd1=document.getElementById("pwd1").value;
var pwd2=document.getElementById("pwd2").value;
if(pwd1!=pwd2){
alert("您输入的密码不一致,请进行核对");
return false;
}
return true;
var pwd1=document.getElementById("pwd1").value;
var pwd2=document.getElementById("pwd2").value;
if(pwd1!=pwd2){
alert("您输入的密码不一致,请进行核对");
return false;
}
return true;
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询