You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Peng, Meimin" <mp...@atxg.com> on 2004/10/01 19:49:15 UTC

validation - mask help

Hi, 
Please help.
I want to use strut's validation to validate a form field called number.
This field allows to input text, number and -.

The code bellows right now is only to validate text and number without
space.
How can I make it work with '-'?
Thanks.

        <form name="NumEditForm">
            <field
                property="value"
                depends="mask">
                <msg name="mask"
                    key="errors.maskmsg"/>
                <arg0 key="errors.maskmsg.form.num.edit.value"/>
                <var>
                    <var-name>mask</var-name>
                    <var-value>^[0-9a-zA-Z]*$</var-value>
                </var>
           </field>           
        </form>   
--M

CONFIDENTIALITY NOTICE:  The information in this e-mail is privileged and
confidential.  Any use, copying or dissemination of any portion of this
e-mail by or to anyone other than the intended recipient(s) is unauthorized.
If you have received this e-mail in error, please reply to sender and delete
it from your system immediately.

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


Re: validation - mask help

Posted by Jeff Beal <jb...@webmedx.com>.
Peng, Meimin wrote:
> Hi, 
> Please help.
> I want to use strut's validation to validate a form field called number.
> This field allows to input text, number and -.
> 
> The code bellows right now is only to validate text and number without
> space.
> How can I make it work with '-'?
> Thanks.
> 
>         <form name="NumEditForm">
>             <field
>                 property="value"
>                 depends="mask">
>                 <msg name="mask"
>                     key="errors.maskmsg"/>
>                 <arg0 key="errors.maskmsg.form.num.edit.value"/>
>                 <var>
>                     <var-name>mask</var-name>
>                     <var-value>^[0-9a-zA-Z]*$</var-value>
>                 </var>
>            </field>           
>         </form>   
> --M
> 
> CONFIDENTIALITY NOTICE:  The information in this e-mail is privileged and
> confidential.  Any use, copying or dissemination of any portion of this
> e-mail by or to anyone other than the intended recipient(s) is unauthorized.
> If you have received this e-mail in error, please reply to sender and delete
> it from your system immediately.

What about <var-value>^-?[0-9a-zA-Z]+$</var-value>
That will allow you to enter any positive or negative hexadecimal number.

If you want to allow any of the following:

a--
612-6a-3461
--bc391

you'll need to do something different.