How should I validate an e-mail address?

后端 未结 30 1646
臣服心动
臣服心动 2020-11-22 08:25

What\'s a good technique for validating an e-mail address (e.g. from a user input field) in Android? org.apache.commons.validator.routines.EmailValidator doesn\'t seem to be

30条回答
  •  感情败类
    2020-11-22 09:17

    Try this code.. Its really works..

                if (!email
                        .matches("^[\\w-_\\.+]*[\\w-_\\.]\\@([\\w]+\\.)+[\\w]+[\\w]$"))
                {
                    Toast.makeText(getApplicationContext(), "Email is invalid",
                            Toast.LENGTH_LONG).show();
                    return;
                }
    

提交回复
热议问题