Email Validation function in Android.

Email Validation function in Android.

 

public static boolean isValidEmailAddress(String email) {

String expression=”^[\\w-\\+]+(\\.[\\w]+)*@[\\w-]+(\\.[\\w]+)*(\\.[a-z]{2,})$”;

CharSequence inputStr = email;

Pattern pattern = Pattern.compile(expression, Pattern.CASE_INSENSITIVE);

Matcher matcher = pattern.matcher(inputStr);

if (matcher.matches() && !email.contains(” “)) {

return true;

}

else {

return false;

}

}

Add a Comment