You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by supa charoenchit <na...@hotmail.com> on 2008/01/01 01:38:32 UTC

regex validation problem

Hello, I am having a problem validating a password field.
 
My requirement on my password is that it must be:
8 characters minimum length and contain at least one from each of the following groups: [a-z], [A-Z], and [0-9]. 
 
Here is what I have so far (which is not working):
 
<field name="emp.password">
<field-validator type="requiredstring">
<message key="Required"/>
</field-validator>
<field-validator type="stringlength"> 
<param name="minLength">8</param> 
<message>Must be 8 characters.</message>
</field-validator> 
<field-validator type="regex"> 
<param name="expression">^[a-z]+$</param>
<message>[a-z]</message> 
</field-validator> 
<field-validator type="regex"> 
<param name="expression">^[A-Z]+$</param>
<message>[A-Z]</message> 
</field-validator> 
<field-validator type="regex"> 
<param name="expression">^[0-9]+$</param>
<message>[0-9]</message> 
</field-validator> 
 
When I attempt to submit my form with correct data, it does not submit and states that I need a-z, A-Z, and 0-9.  What is going on here?
 
Here is my struts.xml for referance:
 
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="default" extends="struts-default">
<default-interceptor-ref name="paramsPrepareParamsStack"/>
<action name="Employee" class="action.EmployeeAction" method="edit">
<result name="success" type="redirect-action">EmployeeList!list.action</result>
<result name="input">/jsp/administration/employeeEntry.jsp</result>
<interceptor-ref name="paramsPrepareParamsStack"/>
</action>
</package>
</struts>
_________________________________________________________________
i’m is proud to present Cause Effect, a series about real people making a difference.
http://im.live.com/Messenger/IM/MTV/?source=text_Cause_Effect

RE: regex validation problem

Posted by na...@hotmail.com.
Thanks, I was finally able to figure it out...
 
^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,15}$
> Date: Wed, 2 Jan 2008 21:06:10 -0800> From: ravi_eze@yahoo.com> To: user@struts.apache.org> Subject: Re: regex validation problem> > > hi,> > seems like ur missing validation and workflow interceptors. Try out this> entry in ur xml file:> > ...> <action name="bla bla"class="bla bla Action" method="bla bla">> <interceptor-ref name="scope">> bla bla> </interceptor-ref>> <interceptor-ref name="conversionError" />> <interceptor-ref name="params" />> <interceptor-ref name="validation" />> <interceptor-ref name="workflow" />> <result>bla bla</result>> ...> > hope this helps!> > > > Laurie Harper wrote:> > > > Hmm, sounds like the regex matching is stricter than I assumed. Try > > changing your rules from 'X' to '.*X.*' maybe, e.g. '.*[a-z]+.*'. Try > > commenting two of the regex validations and experimenting with the third > > until you're sure it's doing what you want, then bring the other two > > back and alter them to match.> > > > L.> > > > supa charoenchit wrote:> >> Hi, thanks for the response. I removed the '^' and '$' characters and it> >> still does not pass validation when I enter a valid password. It is a> >> little wierd, when i enter only lower case characters (or only uppercase> >> characters or only numbers), the check works correctly by saying I need> >> to enter [A-Z] and [0-9]... but when I enter those characters, it says> >> that I need to enter all three character groups: [a-z], [A-Z], [0-9].>> >> To: user@struts.apache.org> From: laurie@holoweb.net> Subject: Re: regex> >> validation problem> Date: Tue, 1 Jan 2008 18:38:55 -0500> > supa> >> charoenchit wrote:> > Hello, I am having a problem validating a password> >> field.> > > > My requirement on my password is that it must be:> > 8> >> characters minimum length and contain at least one from each of the> >> following groups: [a-z], [A-Z], and [0-9]. > > > > Here is what I have so> >> far (which is not working):> > > > [...]> > <field-validator> >> type="regex"> > > ^[a-z]+$> > <message>[> > a-z]</message> > > </field-validator> > > <field-validator type="regex"> >> > > ^[A-Z]+$> > <message>[A-Z]</message> > > </field-validator> > >> > <field-validator type="regex"> > > ^[0-9]+$> > <message>[0-9]</message> >> > > </field-validator> > > > > When I attempt to submit my form with correct> > data, it does not submit and states that I need a-z, A-Z, and 0-9. What is> > going on here?> > Well, those regexs say a valid password must start and> > end with one or > more lowercase letters, must also start and end with one> > or more > uppercase letters and must also start and end with one or more> > digits. > That's obviously not possible.> > If you remove the '^' and '$'> > characters from the expressions, you'll > just be testing that the> > characters appear somewhere within the > password, which I think is what> > you meant..> > L.> > >> > ---------------------------------------------------------------------> To> > unsubscribe, e-mail: user-u> > nsubscribe@struts.apache.org> For additional commands, e-mail:> > user-help@struts.apache.org> > >> _________________________________________________________________> >> The best games are on Xbox 360. Click here for a special offer on an> >> Xbox 360 Console.> >> http://www.xbox.com/en-US/hardware/wheretobuy/> > > > > > ---------------------------------------------------------------------> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org> > For additional commands, e-mail: user-help@struts.apache.org> > > > > > > > -- > View this message in context: http://www.nabble.com/regex-validation-problem-tp14563510p14591718.html> Sent from the Struts - User mailing list archive at Nabble.com.> > > ---------------------------------------------------------------------> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org> For additional commands, e-mail: user-help@struts.apache.org> 
_________________________________________________________________
Share life as it happens with the new Windows Live.
http://www.windowslive.com/share.html?ocid=TXT_TAGHM_Wave2_sharelife_122007

Re: regex validation problem

Posted by ravi_eze <ra...@yahoo.com>.
hi,

seems like ur missing validation and workflow interceptors. Try out this
entry in ur xml file:

...
		<action name="bla bla"class="bla bla Action" method="bla bla">
			<interceptor-ref name="scope">
				bla bla
			</interceptor-ref>
			<interceptor-ref name="conversionError" />
			<interceptor-ref name="params" />
			<interceptor-ref name="validation" />
			<interceptor-ref name="workflow" />
			<result>bla bla</result>
...

hope this helps!



Laurie Harper wrote:
> 
> Hmm, sounds like the regex matching is stricter than I assumed. Try 
> changing your rules from 'X' to '.*X.*' maybe, e.g. '.*[a-z]+.*'. Try 
> commenting two of the regex validations and experimenting with the third 
> until you're sure it's doing what you want, then bring the other two 
> back and alter them to match.
> 
> L.
> 
> supa charoenchit wrote:
>> Hi, thanks for the response.  I removed the '^' and '$' characters and it
>> still does not pass validation when I enter a valid password.  It is a
>> little wierd, when i enter only lower case characters (or only uppercase
>> characters or only numbers), the check works correctly by saying I need
>> to enter [A-Z] and [0-9]... but when I enter those characters, it says
>> that I need to enter all three character groups: [a-z], [A-Z], [0-9].>
>> To: user@struts.apache.org> From: laurie@holoweb.net> Subject: Re: regex
>> validation problem> Date: Tue, 1 Jan 2008 18:38:55 -0500> > supa
>> charoenchit wrote:> > Hello, I am having a problem validating a password
>> field.> > > > My requirement on my password is that it must be:> > 8
>> characters minimum length and contain at least one from each of the
>> following groups: [a-z], [A-Z], and [0-9]. > > > > Here is what I have so
>> far (which is not working):> > > > [...]> > <field-validator
>> type="regex"> > > ^[a-z]+$> > <message>[
> a-z]</message> > > </field-validator> > > <field-validator type="regex"> >
> > ^[A-Z]+$> > <message>[A-Z]</message> > > </field-validator> > >
> <field-validator type="regex"> > > ^[0-9]+$> > <message>[0-9]</message> >
> > </field-validator> > > > > When I attempt to submit my form with correct
> data, it does not submit and states that I need a-z, A-Z, and 0-9. What is
> going on here?> > Well, those regexs say a valid password must start and
> end with one or > more lowercase letters, must also start and end with one
> or more > uppercase letters and must also start and end with one or more
> digits. > That's obviously not possible.> > If you remove the '^' and '$'
> characters from the expressions, you'll > just be testing that the
> characters appear somewhere within the > password, which I think is what
> you meant..> > L.> > >
> ---------------------------------------------------------------------> To
> unsubscribe, e-mail: user-u
> nsubscribe@struts.apache.org> For additional commands, e-mail:
> user-help@struts.apache.org> 
>> _________________________________________________________________
>> The best games are on Xbox 360.  Click here for a special offer on an
>> Xbox 360 Console.
>> http://www.xbox.com/en-US/hardware/wheretobuy/
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/regex-validation-problem-tp14563510p14591718.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: regex validation problem

Posted by Laurie Harper <la...@holoweb.net>.
Hmm, sounds like the regex matching is stricter than I assumed. Try 
changing your rules from 'X' to '.*X.*' maybe, e.g. '.*[a-z]+.*'. Try 
commenting two of the regex validations and experimenting with the third 
until you're sure it's doing what you want, then bring the other two 
back and alter them to match.

L.

supa charoenchit wrote:
> Hi, thanks for the response.  I removed the '^' and '$' characters and it still does not pass validation when I enter a valid password.  It is a little wierd, when i enter only lower case characters (or only uppercase characters or only numbers), the check works correctly by saying I need to enter [A-Z] and [0-9]... but when I enter those characters, it says that I need to enter all three character groups: [a-z], [A-Z], [0-9].> To: user@struts.apache.org> From: laurie@holoweb.net> Subject: Re: regex validation problem> Date: Tue, 1 Jan 2008 18:38:55 -0500> > supa charoenchit wrote:> > Hello, I am having a problem validating a password field.> > > > My requirement on my password is that it must be:> > 8 characters minimum length and contain at least one from each of the following groups: [a-z], [A-Z], and [0-9]. > > > > Here is what I have so far (which is not working):> > > > [...]> > <field-validator type="regex"> > > <param name="expression">^[a-z]+$</param>> > <message>[
a-z]</message> > > </field-validator> > > <field-validator type="regex"> > > <param name="expression">^[A-Z]+$</param>> > <message>[A-Z]</message> > > </field-validator> > > <field-validator type="regex"> > > <param name="expression">^[0-9]+$</param>> > <message>[0-9]</message> > > </field-validator> > > > > When I attempt to submit my form with correct data, it does not submit and states that I need a-z, A-Z, and 0-9. What is going on here?> > Well, those regexs say a valid password must start and end with one or > more lowercase letters, must also start and end with one or more > uppercase letters and must also start and end with one or more digits. > That's obviously not possible.> > If you remove the '^' and '$' characters from the expressions, you'll > just be testing that the characters appear somewhere within the > password, which I think is what you meant..> > L.> > > ---------------------------------------------------------------------> To unsubscribe, e-mail: user-u
nsubscribe@struts.apache.org> For additional commands, e-mail: user-help@struts.apache.org> 
> _________________________________________________________________
> The best games are on Xbox 360.  Click here for a special offer on an Xbox 360 Console.
> http://www.xbox.com/en-US/hardware/wheretobuy/


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


RE: regex validation problem

Posted by supa charoenchit <na...@hotmail.com>.
Hi, thanks for the response.  I removed the '^' and '$' characters and it still does not pass validation when I enter a valid password.  It is a little wierd, when i enter only lower case characters (or only uppercase characters or only numbers), the check works correctly by saying I need to enter [A-Z] and [0-9]... but when I enter those characters, it says that I need to enter all three character groups: [a-z], [A-Z], [0-9].> To: user@struts.apache.org> From: laurie@holoweb.net> Subject: Re: regex validation problem> Date: Tue, 1 Jan 2008 18:38:55 -0500> > supa charoenchit wrote:> > Hello, I am having a problem validating a password field.> > > > My requirement on my password is that it must be:> > 8 characters minimum length and contain at least one from each of the following groups: [a-z], [A-Z], and [0-9]. > > > > Here is what I have so far (which is not working):> > > > [...]> > <field-validator type="regex"> > > <param name="expression">^[a-z]+$</param>> > <message>[a-z]</message> > > </field-validator> > > <field-validator type="regex"> > > <param name="expression">^[A-Z]+$</param>> > <message>[A-Z]</message> > > </field-validator> > > <field-validator type="regex"> > > <param name="expression">^[0-9]+$</param>> > <message>[0-9]</message> > > </field-validator> > > > > When I attempt to submit my form with correct data, it does not submit and states that I need a-z, A-Z, and 0-9. What is going on here?> > Well, those regexs say a valid password must start and end with one or > more lowercase letters, must also start and end with one or more > uppercase letters and must also start and end with one or more digits. > That's obviously not possible.> > If you remove the '^' and '$' characters from the expressions, you'll > just be testing that the characters appear somewhere within the > password, which I think is what you meant.> > L.> > > ---------------------------------------------------------------------> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org> For additional commands, e-mail: user-help@struts.apache.org> 
_________________________________________________________________
The best games are on Xbox 360.  Click here for a special offer on an Xbox 360 Console.
http://www.xbox.com/en-US/hardware/wheretobuy/

Re: regex validation problem

Posted by Laurie Harper <la...@holoweb.net>.
supa charoenchit wrote:
> Hello, I am having a problem validating a password field.
>  
> My requirement on my password is that it must be:
> 8 characters minimum length and contain at least one from each of the following groups: [a-z], [A-Z], and [0-9]. 
>  
> Here is what I have so far (which is not working):
>  
> [...]
> <field-validator type="regex"> 
> <param name="expression">^[a-z]+$</param>
> <message>[a-z]</message> 
> </field-validator> 
> <field-validator type="regex"> 
> <param name="expression">^[A-Z]+$</param>
> <message>[A-Z]</message> 
> </field-validator> 
> <field-validator type="regex"> 
> <param name="expression">^[0-9]+$</param>
> <message>[0-9]</message> 
> </field-validator> 
>  
> When I attempt to submit my form with correct data, it does not submit and states that I need a-z, A-Z, and 0-9.  What is going on here?

Well, those regexs say a valid password must start and end with one or 
more lowercase letters, must also start and end with one or more 
uppercase letters and must also start and end with one or more digits. 
That's obviously not possible.

If you remove the '^' and '$' characters from the expressions, you'll 
just be testing that the characters appear somewhere within the 
password, which I think is what you meant.

L.


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