Email validation regex - client vs. server

2012-10-06 Thread
Hi all,

I'm using @EmailValidator annotation to check an email address.
The Struts2 documentation http://struts.apache.org/2.x/docs/email-validator.
html(http://struts.apache.org/2.x/docs/email-validator.html) mentions that
following regular expression is being used to check the email address:

\\b(^[_A-Za-z0-9-](\\.[_A-Za-z0-9-])*@([A-Za-z0-9-])+((\\.com)|(\\.net)|(\\.org)|(\\.info)|(\\.edu)|(\\.mil)|(\\.gov)|(\\.biz)|(\\.ws)|(\\.us)|(\\.tv)|(\\.cc)|(\\.aero)|(\\.arpa)|(\\.coop)|(\\.int)|(\\.jobs)|(\\.museum)|(\\.name)|(\\.pro)|(\\.travel)|(\\.nato)|(\\..{2,3})|(\\..{2,3}\\..{2,3}))$)\\b

I'm just wondering why following regular expression is actually being
generated for the client side validation instead of the first one? (This is
what I see in the generated HTML page)
/\b(^[_A-Za-z0-9-]+(\.[_A-Za-z0-9-]+)*@([A-Za-z0-9-])+(\.[A-Za-z0-9-]+)*((\.
[A-Za-z0-9]{2,})|(\.[A-Za-z0-9]{2,}\.[A-Za-z0-9]{2,}))$)\b/gi

The reason why I ask this question is that the client side validation (using
the second reg ex) considers for example this address aaa@aa.aaa
(mailto:aaa@aa.aaa) as a valid email address.
Do I miss something or is it a bug?

Martin

Re: Email validation regex - client vs. server

2012-10-06 Thread Lukasz Lenart
2012/10/6  :
> Hi all,
>
> I'm using @EmailValidator annotation to check an email address.
> The Struts2 documentation http://struts.apache.org/2.x/docs/email-validator.
> html(http://struts.apache.org/2.x/docs/email-validator.html) mentions that
> following regular expression is being used to check the email address:
>
> \\b(^[_A-Za-z0-9-](\\.[_A-Za-z0-9-])*@([A-Za-z0-9-])+((\\.com)|(\\.net)|(\\.org)|(\\.info)|(\\.edu)|(\\.mil)|(\\.gov)|(\\.biz)|(\\.ws)|(\\.us)|(\\.tv)|(\\.cc)|(\\.aero)|(\\.arpa)|(\\.coop)|(\\.int)|(\\.jobs)|(\\.museum)|(\\.name)|(\\.pro)|(\\.travel)|(\\.nato)|(\\..{2,3})|(\\..{2,3}\\..{2,3}))$)\\b
>
> I'm just wondering why following regular expression is actually being
> generated for the client side validation instead of the first one? (This is
> what I see in the generated HTML page)
> /\b(^[_A-Za-z0-9-]+(\.[_A-Za-z0-9-]+)*@([A-Za-z0-9-])+(\.[A-Za-z0-9-]+)*((\.
> [A-Za-z0-9]{2,})|(\.[A-Za-z0-9]{2,}\.[A-Za-z0-9]{2,}))$)\b/gi
>
> The reason why I ask this question is that the client side validation (using
> the second reg ex) considers for example this address aaa@aa.aaa
> (mailto:aaa@aa.aaa) as a valid email address.
> Do I miss something or is it a bug?
>
> Martin

I think the docs are wrong, in code I see

\\b(^['_A-Za-z0-9-]+(\\.['_A-Za-z0-9-]+)*@([A-Za-z0-9-])+(\\.[A-Za-z0-9-]+)*((\\.[A-Za-z0-9]{2,})|(\\.[A-Za-z0-9]{2,}\\.[A-Za-z0-9]{2,}))$)\\b

So please register an issue


Kind regards
-- 
Ɓukasz
+ 48 606 323 122 http://www.lenart.org.pl/

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



struts2 disable validation on page load

2012-10-06 Thread prashid
I am using xml based validation.

*Problem:*

I don't want validation to perform on input form when page loaded first time
because all the fields are blank for user to fill in. Suppose for register
form to add new student. It should perform once I click the button.

*Note:* /I want to retain same url even when I do the validation on button
click. New form URL is http://localhost:8000/Struts2_Spring_Crud/student/add
and if validation fail even than the url should be same./

*struts.xml*



list
/student.edit.tiles


*input form*


















--
View this message in context: 
http://struts.1045723.n5.nabble.com/struts2-disable-validation-on-page-load-tp5710743.html
Sent from the Struts - User mailing list archive at Nabble.com.

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



Re: struts2 disable validation on page load

2012-10-06 Thread prashid
Thanks,

if I do processing as   than the
URL will change to /processAdd from /add if input error is generated. How I
stop it from changing URL thus not validate on page load. That's what I
want?




On Sun, Oct 7, 2012 at 9:19 AM, Chris Pratt [via Struts] <
ml-node+s1045723n5710744...@n5.nabble.com> wrote:

> By default Struts 2 validates all methods of the action, except the
> "input", "back", "cancel", or "browse" methods.  One popular solution to
> your problem is to prepare the form data in the input() method, then
> process the form in the execute() method.  To do this you'd need to change
> your setup to:
>
> 
>   list
>   /student.edit.tiles
> 
>
> 
>   list
>   /student.edit.tiles
> 
>
> Then change your form declaration to:
>
> 
>
>   (*Chris*)
>
> On Sat, Oct 6, 2012 at 9:02 PM, prashid <[hidden 
> email]>
> wrote:
>
> > I am using xml based validation.
> >
> > *Problem:*
> >
> > I don't want validation to perform on input form when page loaded first
> > time
> > because all the fields are blank for user to fill in. Suppose for
> register
> > form to add new student. It should perform once I click the button.
> >
> > *Note:* /I want to retain same url even when I do the validation on
> button
>
> > click. New form URL is
> > http://localhost:8000/Struts2_Spring_Crud/student/add
> > and if validation fail even than the url should be same./
> >
> > *struts.xml*
> >
> >
> >  > method="insertOrUpdateStudent">
> > list
> >  type="tiles">/student.edit.tiles
> > 
> >
> > *input form*
> >
> > 
> > 
> >
> > 
> > 
> > 
> >
> > 
> > 
> >
> > 
> > 
> >
> >
> >
> >
> >
> > --
> > View this message in context:
> >
> http://struts.1045723.n5.nabble.com/struts2-disable-validation-on-page-load-tp5710743.html
> > Sent from the Struts - User mailing list archive at Nabble.com.
> >
> > -
> > To unsubscribe, e-mail: [hidden 
> > email]
> > For additional commands, e-mail: [hidden 
> > email]
> >
> >
>
>
> --
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://struts.1045723.n5.nabble.com/struts2-disable-validation-on-page-load-tp5710743p5710744.html
>  To unsubscribe from struts2 disable validation on page load, click 
> here
> .
> NAML
>




--
View this message in context: 
http://struts.1045723.n5.nabble.com/struts2-disable-validation-on-page-load-tp5710743p5710745.html
Sent from the Struts - User mailing list archive at Nabble.com.

Re: struts2 disable validation on page load

2012-10-06 Thread Chris Pratt
Set the failure result of the processAdd to redirect to the add action.
  (*Chris*)

On Sat, Oct 6, 2012 at 10:30 PM, prashid  wrote:

> Thanks,
>
> if I do processing as   than the
> URL will change to /processAdd from /add if input error is generated. How I
> stop it from changing URL thus not validate on page load. That's what I
> want?
>
>
>
>
> On Sun, Oct 7, 2012 at 9:19 AM, Chris Pratt [via Struts] <
> ml-node+s1045723n5710744...@n5.nabble.com> wrote:
>
> > By default Struts 2 validates all methods of the action, except the
> > "input", "back", "cancel", or "browse" methods.  One popular solution to
> > your problem is to prepare the form data in the input() method, then
> > process the form in the execute() method.  To do this you'd need to
> change
> > your setup to:
> >
> >  method="input">
> >   list
> >   /student.edit.tiles
> > 
> >
> > 
> >   list
> >   /student.edit.tiles
> > 
> >
> > Then change your form declaration to:
> >
> > 
> >
> >   (*Chris*)
> >
> > On Sat, Oct 6, 2012 at 9:02 PM, prashid <[hidden email]<
> http://user/SendEmail.jtp?type=node&node=5710744&i=0>>
> > wrote:
> >
> > > I am using xml based validation.
> > >
> > > *Problem:*
> > >
> > > I don't want validation to perform on input form when page loaded first
> > > time
> > > because all the fields are blank for user to fill in. Suppose for
> > register
> > > form to add new student. It should perform once I click the button.
> > >
> > > *Note:* /I want to retain same url even when I do the validation on
> > button
> >
> > > click. New form URL is
> > > http://localhost:8000/Struts2_Spring_Crud/student/add
> > > and if validation fail even than the url should be same./
> > >
> > > *struts.xml*
> > >
> > >
> > >  > > method="insertOrUpdateStudent">
> > > list
> > >  > type="tiles">/student.edit.tiles
> > > 
> > >
> > > *input form*
> > >
> > > 
> > > 
> > >
> > > 
> > > 
> > > 
> > >
> > > 
> > > 
> > >
> > > 
> > > 
> > >
> > >
> > >
> > >
> > >
> > > --
> > > View this message in context:
> > >
> >
> http://struts.1045723.n5.nabble.com/struts2-disable-validation-on-page-load-tp5710743.html
> > > Sent from the Struts - User mailing list archive at Nabble.com.
> > >
> > > -
> > > To unsubscribe, e-mail: [hidden email]<
> http://user/SendEmail.jtp?type=node&node=5710744&i=1>
> > > For additional commands, e-mail: [hidden email]<
> http://user/SendEmail.jtp?type=node&node=5710744&i=2>
> > >
> > >
> >
> >
> > --
> >  If you reply to this email, your message will be added to the discussion
> > below:
> >
> >
> http://struts.1045723.n5.nabble.com/struts2-disable-validation-on-page-load-tp5710743p5710744.html
> >  To unsubscribe from struts2 disable validation on page load, click here<
> http://struts.1045723.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5710743&code=cGlyemFkYS5yYXNoaWRAZ21haWwuY29tfDU3MTA3NDN8MTM5MjQ5MDQ5MQ==
> >
> > .
> > NAML<
> http://struts.1045723.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
> >
> >
>
>
>
>
> --
> View this message in context:
> http://struts.1045723.n5.nabble.com/struts2-disable-validation-on-page-load-tp5710743p5710745.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>