I'm validating about 10 input fileds in a form. The ValidationMessageFor-tags should be at the top of the page, so I'm writing every one like:
@Html.ValidationMessageFor(model => model.Customer.ADDRESS.NAME)
@Html.ValidationMessageFor(model => model.Customer.ADDRESS.CITY)
and so on. My Models look like this:
[Required(ErrorMessage = Constants.ErrorMsgNameMissing)]
public string NAME { get; set; }
[Required(ErrorMessage = Constants.ErrorMsgCityMissing)]
public string CITY { get; set; }
The constants are Strings.
Now, if more than one ValidationMessageFor is shown, they are all in one line.
How can I insert a line break like <br />
at the end of every message?
This is NOT the right way:
@Html.ValidationMessageFor(model => model.Customer.ADDRESS.NAME)<br />
@Html.ValidationMessageFor(model => model.Customer.ADDRESS.CITY)<br />
since the <br />
is shown even if there is no error...;)
Thanks in advance.
PS: Displaying them as a list would also be great.