js判断文本框输入的值
java吧
全部回复
仅看楼主
level 5
八戒008 楼主
在一个JSP页面中 从SERVLET中传入一个PASSWORD String password = (String)session.getAttribute("password");然后在JS中 var opw1 = document.getElementById("pw1"); 怎么判断OPW1的VALUE属性和PASSWORD相等啊!
2008年06月14日 02点06分 1
level 0
有你这么传的吗...
2008年06月14日 02点06分 2
level 5
八戒008 楼主
杂啦? 我传的不对?
2008年06月14日 02点06分 3
level 1
这样的话,你有几种方法可以用,用得比较多的:1。传过来一个MD5加密的PASSWORD放隐藏域,再对你的PW1进行加密后对比。。。2。用AJAX把PW1上传到服务器进行对比,返回对比结果
2008年06月14日 02点06分 4
level 5
八戒008 楼主
我这里做的就是本地对比! 我做的这个页面就是更改密码的这个功能!String password = (String)session.getAttribute("password"); 这个password就是你登陆的时候输入的password, 然后你更改密码的时候要是在旧密码文本框里输入的不是这个password 然后就提示错误信息。 关键是现在不会用旧密码文本框里的值和password比较 opw1.value == password 和opw1.value.equals(password)也不行
2008年06月14日 03点06分 5
level 1
在一个JSP页面中: String password = (String)session.getAttribute("password"); 然后在JS中:var opw1 = document.getElementById("pw1"); var js_password = <%=password%>;if(opw1.value.equals(js_password)){ alert("equal!");}else{ alert("not equal!");}
2008年06月14日 09点06分 6
+1,不过这个是项目的话,估计老板要抽人了...
2013年09月30日 06点09分
level 1
顶6楼
2008年06月14日 09点06分 7
1