Skip to content

Instantly share code, notes, and snippets.

@kalvian1060
Created May 30, 2017 04:10
Show Gist options
  • Save kalvian1060/eaac958d78ca919a38271e05b496a1a5 to your computer and use it in GitHub Desktop.
Save kalvian1060/eaac958d78ca919a38271e05b496a1a5 to your computer and use it in GitHub Desktop.
final EditText emailValidate = (EditText)findViewById(R.id.textMessage);
final TextView textView = (TextView)findViewById(R.id.text);
String email = emailValidate.getText().toString().trim();
String emailPattern = "[a-zA-Z0-9._-]+@[a-z]+\\.+[a-z]+";
// onClick of button perform this simplest code.
if (email.matches(emailPattern))
{
Toast.makeText(getApplicationContext(),"valid email address",Toast.LENGTH_SHORT).show();
}
else
{
Toast.makeText(getApplicationContext(),"Invalid email address", Toast.LENGTH_SHORT).show();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment