Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to validate email id with special characters + Validation FrameWork

 
Maneesh Chauahn
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I have a question on the struts validation framework. As i am using the email rule to validate the email. When i am
put a@yahoo.com in the email field on the JSP then email rule of the validation framework , correctly validate the email id
but when i put �a@yahoo.com ( � is a special character) in the email field on the JSP then this email get failed.

As i checked in the code of the validation framework, in the code email can check character from in between
^[\\000-\\177] range , and it may possible that � has character value than 177 .

So can we handle the email id that contains the characters whose value are greater than 177.

Is there any plugin that support of special characters in the email id


Thanks in the advance from your prompt answer

Maneesh Chauhan
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you'd like to define your own rules for validating an email address, I'd suggest using the mask validation rule. With this rule, you can match the input against any regular expression you specify. That's really all the email rule is anyway is anyway: a special case of the match rule. For more information see the Struts documentation.
 
Joan Horta Tosas
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You know that UTF8 email addresses are still no standard? I think some servers are implementing it, but that addresses can only be used inside that server domain; when an email needs to "get out" of it, it needs to be translated into ASCII (by the moment). So is there any real reason you must accept this kind of emails (like an app that can only be used inside the same domain)?
 
Maneesh Chauahn
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
With the mask property you can validate the characters that can be entered in the field, which is fine ...But when you going to validate through the email validate rule then in that case we have faliure of the email id


Thanks in advance for your prompt answer

Maneesh Chauhan
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What I'm telling you is to use the mask rule instead of the email rule, and not use the email rule at all.
 
omkar patkar
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
H Maneesh,

Merill is RIGHT ! ... you can write your own regularExpression for email as per your requirements. You can refer to some sample examples for regular expressions on the internet and use them in your mask. You can also refer to http://www.regular-expressions.info/

... hope this helps !


Thanks
mkar Patkar
 
Nyanas Kandhan
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For an example on email validation refer here. Struts Email Validation Example
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic