I am developing an app in which I have some edit Text and some validation on them but when I enter "JJJJ@GMAil.cOM" it except and also for "JJJJ@JJj.com". how do I do validation for that here is code:-
public boolean validation(String mobile, String pass) {
if (mobile != null && mobile.length() > 7 && mobile.length() < 15) {
if (pass.length() >= 4 && pass.length() <= 8) {
return true;
} else {
m_InputPassword.setError("Password must be between 4 to 8 characters long");
return false;
}
} else {
m_InputMobile.setError("Mobile number must be between 7 to 15 characters long");
return false;
}
}
private boolean isValidEmail(String email) {
String regExpn = "^(([\\w-]+\\.)+[\\w-]+|([a-zA-Z]{1}|[\\w-]{2,}))@" + "((([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\\.([0-1]?" + "[0-9]{1,2}|25[0-5]|2[0-4][0-9])\\."
+ "([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\\.([0-1]?" + "[0-9]{1,2}|25[0-5]|2[0-4][0-9])){1}|" + "([a-zA-Z]+[\\w-]+\\.)+[a-zA-Z]{2,4})$";
CharSequence inputStr = email;
Pattern pattern = Pattern.compile(regExpn, Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(inputStr);
if (matcher.matches())
return true;
else
return false;
}