Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

coding for email address validation in xamarin.android visual studio 2015?

what is the coding of email address validation using C# in xamarin.android visual studio 2015 and also tell me if any name space is requried? please tell me all the imp step as well as coding for email address validation in edittext. i am new in android.xamarin.. guys please help me

like image 595
shumeza Avatar asked Sep 13 '25 04:09

shumeza


1 Answers

You can use Regex for email validation.

First add following using statement

using System.Text.RegularExpressions;

And after that use following helper method for validation:

Regex EmailRegex = new Regex (@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$");
public bool ValidateEmail(string email)
{
    if (string.IsNullOrWhiteSpace(email))
        return false;

    return EmailRegex.IsMatch(email);
}

Option 2:

Xamarin.Android has a helper method for email validation you also use that:

Android.Util.Patterns.EmailAddress.Matcher(email).Matches();
like image 123
Adnan Umer Avatar answered Sep 15 '25 17:09

Adnan Umer