Thursday, February 7, 2013

email validation in android




protected final Pattern EMAIL_ADDRESS_PATTERN = Pattern
.compile("[a-zA-Z0-9\\+\\.\\_\\%\\-\\+]{1,256}" + "\\@"
+ "[a-zA-Z0-9][a-zA-Z0-9\\-]{0,64}" + "(" + "\\."
+ "[a-zA-Z0-9][a-zA-Z0-9\\-]{0,25}" + ")+");

/**
* for email validation
*
* @param str
*            = string for validation
* @return true if validation is correct
*/
public boolean emailValidation(String str) {
if (str.equals("")
|| EMAIL_ADDRESS_PATTERN.matcher(str).matches() == false)
return false;
else
return true;
}

No comments:

Post a Comment