• Post Reply Bookmark Topic Watch Topic
  • New Topic

any logic to validate an email address

 
kiran manohar
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
is there any code to validate an email address.
Thanks
Kiranmanohar
 
Joel McNary
Bartender
Posts: 1840
Eclipse IDE Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Depends on how you want to validate it. If you simply want to validate the format, then you need to use the java.util.regex package. An email address should be in the form:
[A-Za-z1-0]*@[A-Za-z1-0]*\.[A-Za-z1-0]*
that is, any number of alpha-numeric characters followed by an ampersand followed by any number of alpha-numeric characters followed by a '.' followed by any number of alpha-numeric characters.
If you want to validate if it is a valid address (instead of somehting like zaphod@sneebletrixzer.grt), then you will need to send an e-mail to that address and see it if is received (does not bounce).
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!