2

I have this email validation attribute

[EmailAddress]
[StringLength(50, ErrorMessage = "Email is too long!")]
public string Email { get; set; }

And it works fine, but the problem is when I type the email, and then erase it, the form still asks me to insert correct email even though the field is not required.

enter image description here

Selim Yildiz
  • 5,254
  • 6
  • 18
  • 28

1 Answers1

1

it will accept empty string or exact an email id

"^$|^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$"

Answer

Jigar Sangoi
  • 159
  • 6