修改密码的问题??
现在有2个问题,1,我的数据库里面只有pwd密码这个 字段,新密码这个字段应该在数据库里面不需要字段的啦,
我修改密码可以成功,但是就是比较用户输入的旧密码时,总是弹出alert("旧密码不正确"); 因为我在
旧密码的input里面没有给他nama=pwd,如果给了,那在给新密码里面name属性给什么啊,如果在再新密码框里面给,
name=pwd,系统就会它无法判断name=pwd,到底是谁给你,最后结果是用旧密码和新密码都会等不就去,我就是不知道该怎能办了
2,如果我没有填旧密码,它弹出了一个旧密码不能为空的框,但是我点了确定后 ,它还是可以提交,我不知道要怎么才
能,当它出现错误的信息时,阻止它提交,只有在全部正确的情况下,才能让它提交。
虚心求教。。。。。
我用struts2做的,action ,dao 和struts.xml的配置文件都是正确的,就是jsp页面还有点问题。
//修改密码的jsp页面   
<script>
function updatePwd(){	
	var oldpwd = "${info.pwd}";  
	var old = document.getElementById("old").value;
	var news = document.getElementById("news").value;
	var repnew = document.getElementById("repnew").value;		
	if(oldpwd != old){
		alert("旧密码不正确");
	}	
	if(old ==""){
		alert("旧密码不能为空");
	}
	if(news==""){
		alert("旧密码不能为空");
	}
	if(repnew==""){
		alert("确认密码不能为空");
	}
	if(news != repnew){
		alert("两次输入的密码不一致");
	}	
}
</script>
   </head>    
   <body>
     	<div>
	    	<form action="gaipwd!updatePwd.action" method="post">
	    		<table border="1" width="400" height="130" cellpadding="5">
	    			<tr><th>欢迎进入修改密码的页面</th></tr>
	    			<tr>
	    				<td><input type="hidden" name="id" value="${info.id}" /></td>
	    			</tr>
	    			<tr>
	    				<td>旧密码:  <input type="password" size="19" id="old" /></td>
	    			</tr>
	    			<tr>
	    				<td>新密码:  <input type="password" name="pwd" id="news" /></td>
	    			</tr>
	    			<tr>
	    				<td>确认密码:<input type="password" id="repnew"/></td>
	    			</tr>	
	    			<tr>
	    				<td>
	    					<input type="submit" value="登录" onclick="updatePwd()"/>
	    					<input type="reset" value="重置" />
	    				</td>
	    			</tr>
	    		</table>
	    	</form>
     	</div>
   </body>    
</html>
------解决方案--------------------你取input中的id值去取值和比较验证旧密码,id是唯一的,旧密码你需要先取到现在数据库中的值去和你输入的值去比较,不正确就return下,这样错误就不会执行下去
------解决方案--------------------SQL code
update userinfo set pwd=#PWD where username=#USERNAME and pwd=#OLD;
------解决方案--------------------
界面上两个密码<input>,你完全可以这样啊。
HTML code
<input type='password' name='oldPwd' />
<input type='password' name='newPwd' />