You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Andy Kriger <ak...@greaterthanone.com> on 2003/03/21 00:06:09 UTC

form validation question

I have a validation rule that looks like this...

<field property="phoneExt"
	depends="mask">
	<arg0 key="phone"/>
	<arg1 key="phone.ext"/>
	<var>
		<var-name>mask</var-name>
		<var-value>^\s*\d*\s*$</var-value>
	</var>
</field>

However, it considers the phoneExt field required. Can anyone tell me why?
I want the phoneExt field to be optional, and if filled out, to use the
given mask.

thx
andy


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


Re: form validation question

Posted by Dan Allen <da...@mojavelinux.com>.
Andy Kriger (akriger@greaterthanone.com) wrote:

> I have a validation rule that looks like this...
> 
> <field property="phoneExt"
> 	depends="mask">
> 	<arg0 key="phone"/>
> 	<arg1 key="phone.ext"/>
> 	<var>
> 		<var-name>mask</var-name>
> 		<var-value>^\s*\d*\s*$</var-value>
> 	</var>
> </field>
> 
> However, it considers the phoneExt field required. Can anyone tell me why?
> I want the phoneExt field to be optional, and if filled out, to use the
> given mask.
I believe this has been answered several times and that you just
need the newest validation-rules.xml file which makes mask optional
if not filled in, and leave the required up to the
depends="required,mask"

Dan

-- 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
Daniel Allen, <da...@mojavelinux.com>
http://www.mojavelinux.com/
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
"The package said 'Windows 95 or better', so I installed Linux"
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

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


RE: form validation question

Posted by Marco Tedone <m_...@hotmail.com>.
The values specified in the <arg0...arg3> are used by the validator as a
replacement for the generic pattern {0}. If you give a closer look to the
properties you should import(unless you won't specify yours) when using the
validator, one of these will be:

{0} is required

What the <arg0..arg3> causes is actually the value in the {0} to be replaced
by what you specify. So in your case you should see something similar to the
following:

phone(value from bundle) phone.ext(value from bundle) required

or 

phone.ext(value from bundle) required

Marco

> -----Original Message-----
> From: Andy Kriger [mailto:akriger@greaterthanone.com] 
> Sent: Thursday, March 20, 2003 11:06 PM
> To: Struts Users Mailing List
> Subject: form validation question
> 
> 
> I have a validation rule that looks like this...
> 
> <field property="phoneExt"
> 	depends="mask">
> 	<arg0 key="phone"/>
> 	<arg1 key="phone.ext"/>
> 	<var>
> 		<var-name>mask</var-name>
> 		<var-value>^\s*\d*\s*$</var-value>
> 	</var>
> </field>
> 
> However, it considers the phoneExt field required. Can anyone 
> tell me why? I want the phoneExt field to be optional, and if 
> filled out, to use the given mask.
> 
> thx
> andy
> 
> 

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