<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<html>
<head>
<title>My JSP 'Verify.jsp' starting page</title>
<script type = "text/javascript">
function Verify()
{
var username = document.getElementById("username");
var password = document.getElementById("password");
var repassword = document.getElementById("repassword");
if(username.value.length == 0)
{
//alert(typeof username);
alert("用户名不能为空");
return false;
}
if(password.value.length <=6 || password.value.length >= 15)
{
// alert(password.value);
alert("length of password can't invalid");
return false;
}
if(repassword.value.length <=6 || repassword.value.length >= 15)
{
alert("length of repassword can't invalid");
return false;
}
if(password.value != repassword.value)
{
alert("repassword is not same with password");
return false;
}
return true;
}
</script>
</head>
<body>
<form onsubmit = "return Verify()">
username: <input type = "text" name = "username" id = "username"/><br/>
password: <input type = "text" name = "password" id = "passsword"/><br/>
repassword:<input type = "text" name = "repassword" id = "repassword"/> <br/>
<input type = "submit" value = "submit"/>
</form>
</body>
</html>问题:repassword.value.length这样写产生不了密码验证的效果?有人能帮我下么,谢谢!
<html>
<head>
<title>My JSP 'Verify.jsp' starting page</title>
<script type = "text/javascript">
function Verify()
{
var username = document.getElementById("username");
var password = document.getElementById("password");
var repassword = document.getElementById("repassword");
if(username.value.length == 0)
{
//alert(typeof username);
alert("用户名不能为空");
return false;
}
if(password.value.length <=6 || password.value.length >= 15)
{
// alert(password.value);
alert("length of password can't invalid");
return false;
}
if(repassword.value.length <=6 || repassword.value.length >= 15)
{
alert("length of repassword can't invalid");
return false;
}
if(password.value != repassword.value)
{
alert("repassword is not same with password");
return false;
}
return true;
}
</script>
</head>
<body>
<form onsubmit = "return Verify()">
username: <input type = "text" name = "username" id = "username"/><br/>
password: <input type = "text" name = "password" id = "passsword"/><br/>
repassword:<input type = "text" name = "repassword" id = "repassword"/> <br/>
<input type = "submit" value = "submit"/>
</form>
</body>
</html>问题:repassword.value.length这样写产生不了密码验证的效果?有人能帮我下么,谢谢!
解决方案 »
- getHibernateTemplate().save()方法无法真正插入数据
- struts.xml文件位置改变 web.xml修改问题
- 在spring中IOC注入的实例可以使用Object类型去接收吗
- JSF跳转页面成功但是不能显示内容(求助高手和版住)火急
- org.apache.commons.net.ftp.FTPClient 的 listFiles()方法调用报错
- 高分求截取表情
- 真想把jdom公司干掉!!!
- 请问struts里怎么写radio,text,checkbox,谢谢
- 请教用JBUILDER怎么生成部署描述文件? 帮帮我这个刚入门者吧
- 这个题有正确答案吗
- 【工作5年资料分享】
- hibernate中读取并解析映射文件,创建SessionFactory报错
{
alert("repassword is not same with password");
return false;
}
还想干嘛
{
alert("length of repassword can't invalid");
return false;
}
//删除这个判断
<input type = "text" name = "repassword" id = "repassword"/>这也太不规范了吧,密码域明文???<input type = "password" name = "password" id = "passsword"/>
<input type = "password" name = "repassword" id = "repassword"/>取密码长度试试:document.getElementById("repassword").inLength()