I have added a validation message “CountryId custom error” to a view. Problem is it displays when I load the view initially as well as on POST.
<div class="editor-field">
@Html.DropDownList("CountryId", Model.GetCountries, "Please select", "0")
@Html.ValidationMessageFor(m => m.CountryId, "CountryId custom error")
</div>
How can I make it only display on the POST?
If I omit the validation message the view behaves properly showing a default error on POST.
This project was created as an empty MVC app and I deleted the site.css and started again.
You can’t do this if you want the validation to work as there is vital css in main.css that hides the messages!
Doh!!