struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Laurie Harper <>
Subject Re: Struts2 regex validation question
Date Sat, 03 May 2008 00:07:10 GMT
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
&lt; 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[!(^.*(<|>|&lt;|&gt;|&#60;|&#62;)+.*$)]]></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 <, >, ...


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message