validation in struts

haiany body please tellhow to validate password and re-type password with struts validation framework and i am taking date by individually that is day, month and year with different dropdown boxes how to validate these 2 combined together.thanks in advances s
[300 byte] By [ssreddy_scjpa] at [2007-11-26 18:08:52]
# 1

You can use below code:

<form name="testForm">

<field property="oldPassword"

depends="required">

<arg0 key="testChangePassword.oldPasswordLabel"/>

</field>

<field property="newPassword"

depends="required,minlength">

<arg0 key="testChangePassword.newPasswordLabel"/>

<arg1 name="minlength" key="${var:minlength}" resource="false"/>

<var>

<var-name>minlength</var-name>

<var-value>4</var-value>

</var>

</field>

<field property="confirmNewPassword"

depends="required">

<arg0 key="testChangePassword.confirmNewPasswordLabel"/>

</field>

</form>

sudheer_d123a at 2007-7-9 5:40:39 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

hello dear

do these things carefully

1. enable validator framework in struts config.xml file like this

<plug-in className="org.apache.struts.validator.ValidatorPlugIn">

<set-property property="pathnames" value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>

</plug-in>

</struts-config>

2. in ur jsp where this password field is

inside title write

<html:javascript forName="some form bean name tht u have used instuts config file" >

inside <html:form action .... onsubmit="returnValidateFormBeanName(this);"> same as u use in the above line but do care its first letter should be capital.

NOw u have like in this jsp

<html:password property="password"> this property name will be used in validation.xml file.

in validation.xml write

<formset>

<form name="sameuused in strutsconfig and jsp file">

<field property="password"

depends="required">

<arg key="sameuused in strutsconfig and jsp file.password"/>

</field>

</form>

</formset>

then come to message resouce file property file

write

sameuused in strutsconfig and jsp file.password=Password

it will display the java script msg passwor is required

do these things properly

and it will work

this is clent side validaton

i will come to server side validation later

till that u do this

bye

rakesh_thakura at 2007-7-9 5:40:39 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...