Tony's Space

计划 效率 乐观 自强
posts - 2, comments - 1, trackbacks - 0, articles - 0

用validator验证确认密码与密码是否相等

Posted on 2009-04-09 21:44 tony zhou 阅读(1734) 评论(1)  编辑  收藏 所属分类: struts
Tony Zhou   21:37:17

    本文主要解决用validator验证确认密码与密码是否相等的问题,对于validator原理和使用方法介绍不再讨论。

    1.配置消息文件 application.properties .

errors.equal={0} is not equal to {1}.
    2.添加validation.xml代码.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE form-validation PUBLIC
     
"-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.1.3//EN"
     
"http://jakarta.apache.org/commons/dtds/validator_1_1_3.dtd">
<form-validation>
    
<formset>        
        
<form name="registerForm">
            
<field property="username" depends="required,minlength">
                
<arg0 key="login.username"/>
                
<arg1 name="minlength" key="${var:minlength}" resource="false"/>
                
<var>
                    
<var-name>minlength</var-name>
                    
<var-value>5</var-value>
                
</var>
            
</field>
            
<field property="password" depends="required,minlength">
                
<arg0 key="login.password"/>
                
<arg1 name="minlength" key="${var:minlength}" resource="false"/>
                
<var>
                    
<var-name>minlength</var-name>
                    
<var-value>5</var-value>
                
</var>
            
</field>
            
<field property="repassword" depends="required,validwhen">
                
<msg name="validwhen" key="errors.equal"/>
                
<arg0 key="login.repassword"/>
                
<arg1 name="validwhen" key="login.password"/>
                
<var>
                    
<var-name>test</var-name>
                    
<var-value>(password==*this*)</var-value>
                
</var>
            
</field>
        
</form>
        
    
</formset>
</form-validation>

Feedback

# re: 用validator验证确认密码与密码是否相等  回复  更多评论   

2010-06-11 11:00 by 周盼霞
无任何评论

只有注册用户登录后才能发表评论。


网站导航: