帮忙看看我这个regist.html,点击重置怎么也跳转,用户名和确认密码的判断信息咋也不管用,,,, htmljavascript 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <td height="20" colspan="2" align="center"> <input type="button" value="提交" name="B1" onclick="subm()"> <input type="reset" value="重置" name="B2"></td>改成这样点击提交咋没反应了 很明显,你的JS写错了。跑不了。比如这个:if(flog>=3){ flog遍量根本不存在,应为flag,请耐心检查 再比如 <!--alert("可以使用");这个什么<!--是什么东东? 这个倒没什么影响//两个标签功能相似<input type="button" /><button type="button"></button>楼主代码请用代码模板贴出来,而且,别什么代码都贴,贴关键的。让人头大的排版谁愿意看? function submit(){//第一个var flag1;var name1=document.getElementById("username").value;if(name1==""){alert("请认真填写注册信息!");flag1=0}elseif(name1.length>8||name1.length<3){alert("格式不对");document.getElementById("usName").innerHTML = "<font name=usName style='font-size:12px;color=red'>长度要求3~8位</font>";flag1=0;}else{document.getElementById("usName").innerHTML = "<font name=usName style='font-size:12px;color=green'>可以使用</font>";flag1=1;//通过第一个}//第二个var flag2;var name2=document.getElementById("password").value;if(name2==""){alert("请输入密码!");flag2=0}elseif(name2.length>8||name2.length<3){alert("密码格式不对");document.getElementById("ps1").innerHTML = "<font style='font-size:12px;color=red'>长度要求3~8位</font>";flag2=0;}else{document.getElementById("ps1").innerHTML = "<font style='font-size:12px;color=green'>可以使用</font>";flag2=1;//通过第二个}//第三个var flag3;var name3=document.getElementById("passwordAgian").value;if(name3==""){alert("请输入确认密码!");flag3=0}elseif(name2!=name3){alert("密码不匹配");document.getElementById("ps2").innerHTML = "<font style='font-size:12px;color=red'>密码确认不对</font>";flag3=0;}else{document.getElementById("ps2").innerHTML = "<font style='font-size:12px;color=green'>输入正确</font>";flag3=1;//通过第三个}//提交表单if(flag1==1&&flag2==1&&flag3==1){document.regist.submit();}else{alert("表单填写不正确");return false;}}这样就可以了,简单明了。一步一步走嘛 另外你定义的函数不能是function submit(){我上面也忘记改了。submit()这个函数内部本来就有,不能再重定义,改为thissubmit()就可以了 这里也要改<button class="login_button" onClick="return thissubmit()">提交</button> </td> <td> onClick="return thissubmit()"这个是什么意思,submit是自己写的那个函数吗?试了一下怎么还跳转 return submit()你设什么函数名就用哪个比如return res() <button type="reset" name="B2">重置</button>重置改成这个系统函数可以实现了但是<button class="login_button" onClick="return res()">重置</button> </td>没有调用自己建的清空函数res(),而直接跳转了这很诡异 应该是你的函数中返回值的问题,检查一下。我测试了下,单纯以res()这个为例,比如以下这个,就不会跳转。<!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><script>function res(){document.getElementById("username").value="";document.getElementById("password").value="";document.getElementById("passwordAgian").value="";}</script></head><body> <form method="POST" name="regist" action="RegistServlet" ><table style="heigth:100%;widrt:100%"><tr align="center" valign="middle"><td><TABLE width="622"200" border=0 align="center" cellPadding=0cellSpacing=0style="background-image:url(./images/login_Page/logPage.jpg);hrigth:200;width:392"><TBODY><TR valign="middle" align="center"><TD colSpan=3 heigth=40 valign="middle" align="center"><fontface="黑体" size="4px" color="$196ed1"style="padding-left:20px; vertical-align:middle">用户注册</font></TD></TR><TR><td width="80" heigth="20"class="login_td"> 用户名:</td><td width="120" heigth="20" class="login_td"><input type="text" id="username" name="username" value="" style="WIDTH:110px"></td><td id="usName"></td></TR><TR><td width="80" heigth="20"class="login_td"> 密码:</td><td width="120" heigth="20" class="login_td"><input type="password" id="password" name="password" value="" style="WIDTH:110px"></td><td id="ps1"></td></TR><TR><td width="80" heigth="20"class="login_td"> 确认密码:</td><td width="120" heigth="20" class="login_td"><input type="password" id="passwordAgain" name="passwordAgain" value="" style="WIDTH:110px"></td><td id="ps2"></td></TR><TR> <td height="20" colspan="2" align="center"><button class="login_button" type=reset onclick="return res()">重置</button> <button class="login_button" type="submit">提交</button> </td> <td> <td class="login_td"align="left" width=81> <a href="login.jsp">返回</a></td> </TR></TBODY></table></form></body></html> 上面那个弄错了。这个才是:<!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><script>function res(){document.getElementById("username").value="";document.getElementById("password").value="";document.getElementById("passwordAgian").value="";return false;}</script></head><body> <form method="POST" name="regist" action="RegistServlet" ><table style="heigth:100%;widrt:100%"><tr align="center" valign="middle"><td><TABLE width="622"200" border=0 align="center" cellPadding=0cellSpacing=0style="background-image:url(./images/login_Page/logPage.jpg);hrigth:200;width:392"><TBODY><TR valign="middle" align="center"><TD colSpan=3 heigth=40 valign="middle" align="center"><fontface="黑体" size="4px" color="$196ed1"style="padding-left:20px; vertical-align:middle">用户注册</font></TD></TR><TR><td width="80" heigth="20"class="login_td"> 用户名:</td><td width="120" heigth="20" class="login_td"><input type="text" id="username" name="username" value="" style="WIDTH:110px"></td><td id="usName"></td></TR><TR><td width="80" heigth="20"class="login_td"> 密码:</td><td width="120" heigth="20" class="login_td"><input type="password" id="password" name="password" value="" style="WIDTH:110px"></td><td id="ps1"></td></TR><TR><td width="80" heigth="20"class="login_td"> 确认密码:</td><td width="120" heigth="20" class="login_td"><input type="password" id="passwordAgain" name="passwordAgain" value="" style="WIDTH:110px"></td><td id="ps2"></td></TR><TR> <td height="20" colspan="2" align="center"><button class="login_button" type="button" onclick="return res()">重置</button> <button class="login_button" type="submit">提交</button> </td> <td> <td class="login_td"align="left" width=81> <a href="login.jsp">返回</a></td> </TR></TBODY></table></form></body></html> function res(){document.getElementById("username").value="";document.getElementById("password").value="";document.getElementById("passwordAgian").value="";return false;失败的时候一定要返回false,这样就不会跳了 就是没写这个type=reset的问题type=reset这个不是调用的系统函数reset吗,相当于我的函数还是没运行啊 javascript 中无法获取Label值 这个验证错误在哪里? 提高 javascript 效率的插件 javascript 如何使用逆向引用,用正则替换 这样的效果如何实现? 取地址变量及值的方法(不是自己写的),谁知道? 浏览器内存泄露有专门的检测工具吗?欢迎推荐,急!!! 关于WSH,有谁能提供详细的使用方法? 问题简单,取数字中的字符串问题 好多问题!散分! 又是一个难题,求大神帮忙 大学项目,网站注释工具
<input type="button" value="提交" name="B1" onclick="subm()">
<input type="reset" value="重置" name="B2"></td>
改成这样点击提交咋没反应了
<input type="button" />
<button type="button"></button>楼主代码请用代码模板贴出来,而且,别什么代码都贴,贴关键的。让人头大的排版谁愿意看?
var flag1;
var name1=document.getElementById("username").value;
if(name1==""){
alert("请认真填写注册信息!");flag1=0
}elseif(name1.length>8||name1.length<3){
alert("格式不对");
document.getElementById("usName").innerHTML = "<font name=usName style='font-size:12px;color=red'>长度要求3~8位</font>";
flag1=0;
}else{
document.getElementById("usName").innerHTML = "<font name=usName style='font-size:12px;color=green'>可以使用</font>";
flag1=1;//通过第一个
}
//第二个
var flag2;
var name2=document.getElementById("password").value;
if(name2==""){
alert("请输入密码!");flag2=0
}elseif(name2.length>8||name2.length<3){
alert("密码格式不对");
document.getElementById("ps1").innerHTML = "<font style='font-size:12px;color=red'>长度要求3~8位</font>";
flag2=0;
}else{
document.getElementById("ps1").innerHTML = "<font style='font-size:12px;color=green'>可以使用</font>";
flag2=1;//通过第二个
}
//第三个
var flag3;
var name3=document.getElementById("passwordAgian").value;
if(name3==""){
alert("请输入确认密码!");flag3=0
}elseif(name2!=name3){
alert("密码不匹配");
document.getElementById("ps2").innerHTML = "<font style='font-size:12px;color=red'>密码确认不对</font>";
flag3=0;
}else{
document.getElementById("ps2").innerHTML = "<font style='font-size:12px;color=green'>输入正确</font>";
flag3=1;//通过第三个
}//提交表单
if(flag1==1&&flag2==1&&flag3==1){
document.regist.submit();
}else{
alert("表单填写不正确");
return false;
}
}
这样就可以了,简单明了。一步一步走嘛
<td>
这个是什么意思,submit是自己写的那个函数吗?
试了一下怎么还跳转
你设什么函数名就用哪个比如return res()
重置改成这个系统函数可以实现了但是<button class="login_button" onClick="return res()">重置</button> </td>没有调用自己建的清空函数res(),而直接跳转了这很诡异
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script>
function res(){
document.getElementById("username").value="";
document.getElementById("password").value="";
document.getElementById("passwordAgian").value="";
}
</script>
</head><body>
<form method="POST" name="regist" action="RegistServlet" >
<table style="heigth:100%;widrt:100%">
<tr align="center" valign="middle">
<td>
<TABLE width="622"200" border=0 align="center" cellPadding=0
cellSpacing=0
style="background-image:url(./images/login_Page/logPage.jpg);
hrigth:200;width:392"><TBODY>
<TR valign="middle" align="center">
<TD colSpan=3 heigth=40 valign="middle" align="center"><font
face="黑体" size="4px" color="$196ed1"
style="padding-left:20px; vertical-align:middle">用户注册
</font></TD>
</TR>
<TR>
<td width="80" heigth="20"
class="login_td"> 用户名:</td>
<td width="120" heigth="20" class="login_td">
<input type="text" id="username" name="username" value="" style="WIDTH:110px"
></td>
<td id="usName"></td>
</TR>
<TR>
<td width="80" heigth="20"
class="login_td"> 密码:</td>
<td width="120" heigth="20" class="login_td">
<input type="password" id="password" name="password" value="" style="WIDTH:110px"
></td>
<td id="ps1"></td>
</TR>
<TR>
<td width="80" heigth="20"
class="login_td"> 确认密码:</td>
<td width="120" heigth="20" class="login_td">
<input type="password" id="passwordAgain" name="passwordAgain" value="" style="WIDTH:110px"
></td>
<td id="ps2"></td>
</TR>
<TR>
<td height="20" colspan="2" align="center">
<button class="login_button" type=reset onclick="return res()">重置</button>
<button class="login_button" type="submit">提交</button> </td>
<td>
<td class="login_td"align="left" width=81>
<a href="login.jsp">返回</a></td>
</TR>
</TBODY>
</table></form>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script>
function res(){
document.getElementById("username").value="";
document.getElementById("password").value="";
document.getElementById("passwordAgian").value="";
return false;
}
</script>
</head><body>
<form method="POST" name="regist" action="RegistServlet" >
<table style="heigth:100%;widrt:100%">
<tr align="center" valign="middle">
<td>
<TABLE width="622"200" border=0 align="center" cellPadding=0
cellSpacing=0
style="background-image:url(./images/login_Page/logPage.jpg);
hrigth:200;width:392"><TBODY>
<TR valign="middle" align="center">
<TD colSpan=3 heigth=40 valign="middle" align="center"><font
face="黑体" size="4px" color="$196ed1"
style="padding-left:20px; vertical-align:middle">用户注册
</font></TD>
</TR>
<TR>
<td width="80" heigth="20"
class="login_td"> 用户名:</td>
<td width="120" heigth="20" class="login_td">
<input type="text" id="username" name="username" value="" style="WIDTH:110px"
></td>
<td id="usName"></td>
</TR>
<TR>
<td width="80" heigth="20"
class="login_td"> 密码:</td>
<td width="120" heigth="20" class="login_td">
<input type="password" id="password" name="password" value="" style="WIDTH:110px"
></td>
<td id="ps1"></td>
</TR>
<TR>
<td width="80" heigth="20"
class="login_td"> 确认密码:</td>
<td width="120" heigth="20" class="login_td">
<input type="password" id="passwordAgain" name="passwordAgain" value="" style="WIDTH:110px"
></td>
<td id="ps2"></td>
</TR>
<TR>
<td height="20" colspan="2" align="center">
<button class="login_button" type="button" onclick="return res()">重置</button>
<button class="login_button" type="submit">提交</button> </td>
<td>
<td class="login_td"align="left" width=81>
<a href="login.jsp">返回</a></td>
</TR>
</TBODY>
</table></form>
</body>
</html>
document.getElementById("username").value="";
document.getElementById("password").value="";
document.getElementById("passwordAgian").value="";
return false;失败的时候一定要返回false,这样就不会跳了
type=reset这个不是调用的系统函数reset吗,相当于我的函数还是没运行啊