I am developing an app in which I have email edit text field in which I make some validation it works but not properly when I enter email like jj@gm.cim it except that but this is wrong right validation is jj@gmail.com.
How can I do like that?
Here is code:-
public boolean validation(String mobile,String pass,String email){
    if (mobile!=null && mobile.length() >= 7 && mobile.length() <= 15) {
        if (pass.length() >= 4 && pass.length() <= 8) {
            if (isValidEmail(email)) {
                return true;
            } else {
                m_EmailEditText.setError("Invalid EmailID");
                return false;
            }
        } else {
            m_PasswordEditText.setError("password must be between 4 to 8 characters long");
            return false;
        }
    } else {
        m_MobileEditText.setError("mobile number must be between 7 to 51 characters long");
        return false;
    }
}
// This is validation for email……….and link to above code….
private boolean isValidEmail(String email) {
    String emailPattern = "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@"
            + "[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";
    Pattern pattern = Pattern.compile(emailPattern);
    Matcher matcher = pattern.matcher(email);
    return matcher.matches();
}
 
     
     
     
     
     
    