So then how would you test a field that is not required to enter a value into, but if the user does, it must be a valid email address? That is what I am ultimately looking for. Is there a way to achieve this using the validators that exist already, or do I need to create my own?
Daniel -----Original Message----- From: Niall Pemberton [mailto:[EMAIL PROTECTED] Sent: Friday, February 03, 2006 5:02 PM To: Struts Users Mailing List Subject: Re: Validator Question You shouldn't need to use validwhen to do what you describe - try just using email... <field property="notificationBcc" depends="email"> <arg0 key="notification.pref.error.notificationbcc"/> </field> If however you do have reasons for using validwhen then the thing to remember is that the "test" variable specifies the condition when the field is valid. So what you have specified is that this field is valid when "notificationBcc" is null - otherwise it is invalid. So any value you enter in that field will cause a validation error. More recent versions of Struts (from 1.2.7 I think) include a "validwhen" examples page in the struts-examples webapp - which is included in the binary distro. Niall ----- Original Message ----- From: "Kalcevich, Daniel" <[EMAIL PROTECTED]> Sent: Friday, February 03, 2006 11:26 PM Everyone, I am using the validator to validate an email address in a text field. The field is not required, but when there is a value in there, I want it to be a valid email address. Here is my XML, <field property="notificationBcc" depends="validwhen,email"> <arg0 key="notification.pref.error.notificationbcc"/> <var> <var-name>test</var-name> <var-value>(*this* == null)</var-value> </var> </field> But when I enter the value '[EMAIL PROTECTED]' I get an error message saying the field is required. Any ideas? Thanks. Daniel --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]