Skip to main content

Email Address Validation

Lot of peoples validate their field by using field length or Regular Expressions.

In this way, Email Addresses validation has been difficult some times.

Format of Email Address:
The format of email addresses is local-part@domain where the local-part may be up to 64 characters long and the domain name may have a maximum of 253 characters - but the maximum 256 characters length of a forward or reverse path restricts the entire email address to be no more than 254 characters.<sup id="cite_ref-0">[1]</sup> The formal definitions are in RFC 5322 (sections 3.2.3 and 3.4.1) and RFC 5321 - with a more readable form given in the informational RFC 3696<sup id="cite_ref-1">[2]</sup> and the associated errata.

Supported Characters:
The local-part of the email address may use any of these ASCII characters RFC 5322 Section 3.2.3:

  • Uppercase and lowercase English letters (a–z, A–Z) (ASCII: 65-90, 97-122)
  • Digits 0 to 9 (ASCII: 48-57)
  • Characters !#$%&'*+-/=?^_`{|}~ (ASCII: 33, 35-39, 42, 43, 45, 47, 61, 63, 94-96, 123-126)
  • Character . (dot, period, full stop) (ASCII: 46) provided that it is not the first or last character, and provided also that it does not appear two or more times consecutively (e.g. is not allowed.).
  • Special characters are allowed with restrictions. They are:
  • Space and "(),:;<>@[\] (ASCII: 32, 34, 40, 41, 44, 58, 59, 60, 62, 64, 91-93)
  • The restrictions for special characters are that they must only be used when contained between quotation marks, and that 3 of them (The space, backslash \ and quotation mark " (ASCII: 32, 92, 34)) must also be preceded by a backslash \ (e.g. "\ \\\"").
Using in Android:

String email_Pattern = "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@"

+ "[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";

String email= mEmail.getText.toString();

System.out.println("Valid Email Address");
} else {
System.out.println("Invalid Email Address");

Also you can try in TextWatcher interfaces.


Popular posts from this blog

Clear the app data programmatically in android

Clear the App Data Programmatically in Android

Application data has been created due to use shared preference data, databases and network caches data. This data has been manually clear on Settings -- > Apps (or) Application Manager --> Select the app you want to clear the data. --> Then click button clear data to erase the app from the Phone and SDCARD.

Applications like facebook, google+, gmail and some games captures more data on phone and SDCARD.

Once you clear the data of your app, all passwords and saved settings in app has been lost. So carefull to use this method.

Create the Class MyApplication

public class MyApplication extends Application {
 private static MyApplication instance;
 public void onCreate() {
  instance = this;
 public static MyApplication getInstance(){
  return instance;
 public void clearApplicationData() {
  File cache = getCacheDir();
  File appDir = new File(cache.getParent());
   String[] children = app…

Sort the numbers using If, Else and Loop.

This is very interesting. You need to sort the numbers, but not using the SORT functions. You can use the If, Else or Loop to do the functions.

See the solution:

import java.util.Scanner;
public class OrderNumbers {
    public static void main(String[] args) {         Scanner in = new Scanner(;         System.out.println("Enter the size of an Array");         int num = in.nextInt();         int [] numbers = new int[num];         for (int i = 0; i < numbers.length; i++) {             System.out.println("Enter the number "+(i+1)+" : ");             numbers[i] = in.nextInt();         }         sortNumbers(numbers);     }     static void sortNumbers(int[] numbers){         for (int i = 0; i < numbers.length; i++) {             int newValue;             for (int j = 0; j < numbers.length; j++) {                 if (numbers[i] < numbers[j]) {                     newValue = numbers[j];                     numbers[j] = numbers[i];                     numbers[i]…

Record the mobile screens through MyMobiler

Dedicate to all android developers, MyMobiler is very useful for android app developers.


Records the mobile screens.
Screen Capture.
Control your mobile device from the desktop.
Transfer the file between desktop/device
USB/Wifi Connection
Supports from Android OS 2.2 version.

Download the desktop application.

Download the mobile application.

Watch the tutorials about connecting the device and desktop in YouTube: