I have a Account Model in which I am using Email Address as Username
public class RegisterModel
{
[Required]
[Display(Name = "Email Address")]
[DataType(DataType.EmailAddress)]
public string UserName { get; set; }
I have designed a custom class to verify email. But I recently noticed that the DataType.EmailAddress
. I tried to use this Datatype as shown in code above to check if I can validate the Username without my Custom Class but it fails. So my question is how is this DataType useful in .NET
. It seems to be doing nothing on my Registration Form.
Edit: It dosent even validate against a regex. For example Username: SS, ssssss, tttt, etc
all pass off as valid emails.
Edit: People I have a class to validate email in the code behind. I know hat are the complexities of validating Emails. I am not asking how to validate email. I am just asking about the uses of this datatype.