How would I make a basic Java E-mail validation please?


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: How would I make a basic Java E-mail validation please?

  1. #1
    Join Date
    Sep 2004
    Posts
    9

    How would I make a basic Java E-mail validation please?

    I have a basic Java program (in BlueJ) which accepts an E-mail address field from the user - in the constructor how would I make a basic E-mail validation just to ensure it has the correct @ and '.' within the address please?

    I have done a little bit of research on the Internet and found people recommend using regular expressions but I do not really understand.

    Any help would be very much appreciated - thank you in advance :-)

  2. #2
    Join Date
    Oct 2004
    Posts
    311
    You could use regular expressions for that. They are part of the String.matches(String regex) method. This method is called on the email addres, the regex will have to be one which checks for the right syntax. You can find out more about these regular expressions through the following link:
    regex
    There's even an example of email validation there.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center