Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • Tom Bruce 122 posts 506 karma points
    Jan 23, 2018 @ 10:52
    Tom Bruce

    RegisterModel, ProfileModel email validation

    Hi everyone, how do you overwrite the RegisterModel

    The validation of the email address is a regular expression which does not allow to use email addresses with capital letters.

    I need to override this just not sure how to do it, any help or pointers much appreciated.


    [RegularExpression("[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", ErrorMessage = "Please enter a valid e-mail address")]
    public string Email { get; set; }
  • Robert Dyson 50 posts 147 karma points c-trib
    Apr 10, 2018 @ 11:29
    Robert Dyson

    I would also like to know how to do this.. Did you manage to solve it?

  • pranjal 75 posts 188 karma points
    Apr 10, 2018 @ 11:44

    Just use Email Address attribute of Dot net it just work everything for uh regarding email

  • Robert Dyson 50 posts 147 karma points c-trib
    Apr 10, 2018 @ 11:51
    Robert Dyson

    I managed to override the client side validation. However it then throws it back with the server side validation.

    For example you can even do it by amending Umbraco's own regular expression:

         @Html.TextBoxFor(m => registerModel.Email, new
            @class = "form-control",
            @data_val_required = "This field is required.",
            @data_val = "true",
            @data_val_regex = "Please enter a valid email address",
            @data_val_regex_pattern = @"^[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?\.)+[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?$"

    But as I said, when you click submit it comes back with the same error message.

Please Sign in or register to post replies

Write your reply to: