simple way to validate email field, client side on Android.
you can find whole test project from here.
Regards
Imran ali
private boolean isValidEmail(String email) {
Pattern p = Pattern.compile(".+@.+\\.[a-z]+");
Matcher m = p.matcher(email);
boolean matchFound = m.matches();
StringTokenizer st = new StringTokenizer(email, ".");
String lastToken = null;
while (st.hasMoreTokens()) {
lastToken = st.nextToken();
}
if (matchFound && lastToken.length() >= 2
&& email.length() - 1 != lastToken.length()) {
return true;
} else {
return false;
}
}
you can find whole test project from here.
Regards
Imran ali
No comments:
Post a Comment