Email and Password validation and recognizing email pattern

1105 views java
0

I have tried many times to create a class and a method to validate email and password and recognize email pattern which must consists'@' and '.'.Bt I am failing all the times.

answered question

are you using a regex?

String emailPattern = "[a-zA-Z0-9._-]+@[a-z]+\\.+[a-z]+"; if( _student_Email.matches(emailPattern)) { //Do your own tasks. }else{ Toast.makeText(RegistrationActivity.this, "please enter valid email address", Toast.LENGTH_SHORT).show(); }

This will help you.

1 Answer

3

Use this code

public static boolean isValidEmail(CharSequence target) {
      return (!TextUtils.isEmpty(target) && Patterns.EMAIL_ADDRESS.matcher(target).matches());
}

posted this

Have an answer?

JD

Please login first before posting an answer.