I have a model like :
public class MyAnnotationModel
{
public int Id { get; set; }
[Required(ErrorMessage="Name is Required")]
public string Name { get; set; }
public string City { get; set; }
}
In the View Page my HTML is like :
<%Html.EnableClientValidation(); %><%using (Html.BeginForm()) { %> <div> <%=Html.TextBox("MyName",Model.Name)%> <%Html.ValidationMessageFor(m=>m.Name,"*");%> <br /> <input type="submit" id="submit" value="Submit" /> </div><%}%>
But this is not able to display the Client side validation error
message if the 'Name' textbox is empty. How can i achieve this
functionality?
View Complete Post