struts2验证框架,验证密码和确认密码是否相同,怎么验证
2个回答
展开全部
有两种,一个是字段验证,一个是验证器验证
我喜欢应字段验证
<validators>
<field name="password"
<field-validator type="requiredString">
<param name="trim">true</param>
<message>不能为空</message>
</field-validator>
</field>
<field name="againpassword"
<field-validator type="fieldexpression">
<param name="expression"><![CDATA[againpassword==password]]></param>
<message>My credit limit should be MORE than my girlfriend</message>
</field-validator>
</field>
</vaidators>
这个是字段验证~
我喜欢应字段验证
<validators>
<field name="password"
<field-validator type="requiredString">
<param name="trim">true</param>
<message>不能为空</message>
</field-validator>
</field>
<field name="againpassword"
<field-validator type="fieldexpression">
<param name="expression"><![CDATA[againpassword==password]]></param>
<message>My credit limit should be MORE than my girlfriend</message>
</field-validator>
</field>
</vaidators>
这个是字段验证~
展开全部
<script type="text/javascript">
<!--
function checkPassword(){
if(form1.newpass1.value!=form1.newpass2.value){
alert("两次密码输入不一致,请重新输入");
form1.newpass1.value="";
form1.newpass2.value="";
form1.newpass1.focus();
}else if(form1.newpass1.value == "") {
alert("密码不能为空");
form1.newpass1.value="";
form1.newpass2.value="";
form1.newpass1.focus();
}else form1.submit();
}
-->
</script>
<form action="" name="form1">
密码:<input type="password" name="newpass1"/>
确认密码:<input type="password" name="newpass2"/>
</form>
<!--
function checkPassword(){
if(form1.newpass1.value!=form1.newpass2.value){
alert("两次密码输入不一致,请重新输入");
form1.newpass1.value="";
form1.newpass2.value="";
form1.newpass1.focus();
}else if(form1.newpass1.value == "") {
alert("密码不能为空");
form1.newpass1.value="";
form1.newpass2.value="";
form1.newpass1.focus();
}else form1.submit();
}
-->
</script>
<form action="" name="form1">
密码:<input type="password" name="newpass1"/>
确认密码:<input type="password" name="newpass2"/>
</form>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询