You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Pranav <me...@yahoo.com> on 2008/05/03 01:19:43 UTC
Struts2 regex validation question
Hi,
I want to put a validation in struts2 using field-validator type="regex" such that any string which contains any of the <, > or any of the alternative representation like < should return a validation failure message. How do I do that?. I believe that if I give a pattern to regex, it shows error message if it DOES NOT match the pattern but here I know the pattern which the input field must not match in order to be valid. Any help?
<field-validator type="regex">
<param name="expression"><![CDATA[!(^.*(<|>|<|>|<|>)+.*$)]]></param> [i want to provide a pattern such that the input string does not match it]
<message>Input has invalid characters</message>
</field-validator>
Thanks
Pranav
____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Struts2 regex validation question
Posted by Laurie Harper <la...@holoweb.net>.
Pranav wrote:
> Hi,
>
> I want to put a validation in struts2 using field-validator type="regex" such that any string which contains any of the <, > or any of the alternative representation like < should return a validation failure message. How do I do that?. I believe that if I give a pattern to regex, it shows error message if it DOES NOT match the pattern but here I know the pattern which the input field must not match in order to be valid. Any help?
>
> <field-validator type="regex">
> <param name="expression"><![CDATA[!(^.*(<|>|<|>|<|>)+.*$)]]></param> [i want to provide a pattern such that the input string does not match it]
> <message>Input has invalid characters</message>
> </field-validator>
Try <![CDATA[^[^<>...]*$]> -- in other words, match a string of zero or
more characters excluding <, >, ...
L.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org