commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shah, Shrihas \(OFT\)" <Shrihas.S...@oft.state.ny.us>
Subject RE: Validation on An optional field that if supplied passes a validation
Date Wed, 26 May 2004 19:50:12 GMT
HI Mike:

One of the way is to check in your form's validation method. First you
call super.validate  and then call the method GenericValidator' isDate
method to validate the date. Take validation out of validation.xml

Here is the code snippet

	public ActionErrors validate(
		ActionMapping mapping,
		HttpServletRequest request) {


		ActionErrors errors = super.validate(mapping, request);
		GenericValidator gv = new GenericValidator();
		if(!Util.isNull(this.getDob()) &&
!(gv.isDate(getDob(),"MM/dd/yyyy",true)))
		{
			errors.add("dob", new
ActionError("errors.date",getDob()));
		}
		return errors;

	}	

I hope this helps.

Shrihas Shah
NYS Office for Technology
shrihas.shah@oft.state.ny.us
Phone (518) 473-5023
Fax (518) 473-3389
(US Postal Service Regular Mail Address)
State Capitol ESP, PO Box 2062
Albany, NY 12220-0062
(Parcel Post/Overnight and Interagency Mail Address)
Empire State Plaza
Swan St., Core 4, 1st Floor
Albany, NY 12223
 
-----Original Message-----
From: Mike Tedesco [mailto:Mike_Tedesco@skillsoft.com] 
Sent: Wednesday, May 26, 2004 9:01 AM
To: Jakarta Commons Users List
Subject: Validation on An optional field that if supplied passes a
validation

Can someone tell me how I set up a form validation in my xml that can be
optional (i.e. passed as null). But if it is supplied then I can perform
the validation
 
<field

property="email2"

depends="email">

<arg0 key="ilt.Email2"/>

</field>

 

Like above I want only the email validation to be performed if the field
is not null.

 

-- Thanks


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message