-6

I hava an application that has a register frame with all relavant textboxes and combo boxes and buttons.now my problem is when i enter an email on the email textbox it saves in my database regardless of the nonsense i've put in.i want to make sure that the user puts the correct format of the email e.g "example@blhablha.com" even if this email doesn't exist but atleast in looks like an email address im using java by the way.

Your help is highly appreciated in advance.

Lazarus
  • 49
  • 8
  • 6
    have you tried google? I'm pretty sure this issue is heavily covered. – Matten Oct 03 '12 at 13:38
  • 2
    Seriously, do some research: http://stackoverflow.com/questions/8204680/java-regex-email – Roddy of the Frozen Peas Oct 03 '12 at 13:39
  • 1
    Apparently he has not tried google, but still, even if this is an easy answer, as a beginner he/she may not know how to search this (ie that it is a client side code, hence jscript or vbscript and is called "validation") he should have the right to post a simple question here without zillions of downvotes... – sed Oct 03 '12 at 13:41
  • His other questions are about Java, so I'm going to assume he got that part right. – Roddy of the Frozen Peas Oct 03 '12 at 13:43
  • @BeQl no. "textbox check email java" is enough, it's harder to find a title for this site. – Matten Oct 03 '12 at 13:43
  • @Matten actually you are right, touche – sed Oct 03 '12 at 13:43
  • 2
    It's one thing when you try to do something in an ass-backwards way, it's a different thing to ask a VERY common question instead of googling OR searching stackoverflow... even tho it searches for you as you type your issue. A little effort is required. All I see here is "i want" but no "i tried X and got error Y" – Shark Oct 03 '12 at 13:44
  • at least now they learned the importance of searching and trial and error :P – sed Oct 03 '12 at 13:46
  • @Shark thanks for the insult i will bear it in mind.....! – Lazarus Oct 03 '12 at 14:49
  • It is not an insult, it's advice. You are more likely to get answers when you say "i tried X and got errors A,B,C,D...Z" than "I want this". Then we know how you think and can get some insight into what you're trying to do, and can think of why those reasons that you tried might not be working... Saying "i want code that does X" is slightly better than saying "look at this code, it doesn't work!!1!1!" which really gets us nowhere. You need to help us help you, not just throw it in our face and expect a correct answer. Sometimes you'll get it, other times I won't know what you're talking about. – Shark Oct 03 '12 at 14:51
  • @Matten criticizing someone is one thing but making them feel stupid is another thing just remember that,everytime you make a comment.Kind regards – Lazarus Oct 03 '12 at 14:56
  • possible duplicate of [validate that an email address contains "@" and "." ](http://stackoverflow.com/questions/5955739/validate-that-an-email-address-contains-and) – tripleee Oct 03 '12 at 17:52
  • @LazarusMasoga sorry that wasn't my intention. It just happens too often that someone asks a question with a title that would solve the problem when entered into any search engine. – Matten Oct 04 '12 at 08:12

2 Answers2

1

It is really complicated to validate an email address, still there are a bunch of regular expression you can find on the web that will check certain important things, like this one for example ^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$. Unfortunately I don't think there is an ultimate regex that will catch every "non-sense" you can find in an email address.

talnicolas
  • 13,885
  • 7
  • 36
  • 56
0

You need to look into javascript email validation, try following this https://web.archive.org/web/20211020140426/https://www.4guysfromrolla.com/webtech/052899-1.shtml

sed
  • 5,431
  • 2
  • 24
  • 23