I have made both Required and Regular Expression validation working. the only problem is i want to show them both on different location within the page. just like the required validation message will be shown before the textbox. the regular expression validation message will be shown after the textbox. How can i do it?
Here is my model code
[Required(ErrorMessage = "*")]
[RegularExpression(@"^[\w-]+(?:\.[\w-]+)*@(?:[\w-]+\.)+[a-zA-Z]{2,7}$", ErrorMessage = "Invalid Email")]
public string Email { get; set; }
Here is my View code
@Html.ValidationMessageFor(p => p.Email)
@Html.TextBoxFor(p => p.Email)
@Html.LabelFor(p => p.Email, "Email")
On the above code, both error messages will show before the textbox, i want to make something like this
@Html.ValidationMessageFor(p => p.Email) - required validation message which is "*"
@Html.TextBoxFor(p => p.Email)
@Html.LabelFor(p => p.Email, "Email")
@Html.ValidationMessageFor(p => p.Email) - regular expression validation message which is "Invalid Email"