0

Is it possible to convert DataType.EmailAddress to normal email format. Not sure, but in my opinion everything worked well before.

Now:

    [Display(Name="E-mail")]
    [Required(ErrorMessage = "Введите E-mail")] 
    [EmailAddress(ErrorMessage ="The Email field is not a valid e-mail address.")]
    public string Email { get; set; }

Validation will miss the e-mail without a zone.

enter image description here enter image description here

I know I can fix it with regex. But maybe there is possibility to fix the attribute?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
blakcat
  • 634
  • 1
  • 7
  • 16
  • Also the correct address is not vb@gmail. And validation passes it – blakcat Nov 05 '18 at 13:46
  • 1
    That's not true - `vb@gmail` is a *valid* email address (according to the *format* of an email address). See [here](https://stackoverflow.com/questions/20573488/why-does-html5-form-validation-allow-emails-without-a-dot) for more. – Kirk Larkin Nov 05 '18 at 13:47
  • Email address can be without a zone (.com)? – blakcat Nov 05 '18 at 13:49
  • The part after the `@` is literally the mail server's hostname. It's of course typical for that to be a standard online website like `gmail.com`, but it doesn't have to be. You might have a local mailserver at `foo`, in which case `bob@foo` might be a perfectly valid address. – Chris Pratt Nov 05 '18 at 13:52
  • Thanks for the answer. You're right. I would look into the eyes of that person who did this. But as they say. Complicating is simple - difficult to simplify. – blakcat Nov 05 '18 at 14:26

0 Answers0