I have added a text box to a simple form in ASP.NET MVC and I want a client-side ‘required’ validation for this.
I know I can do this using a strongly typed model view but I would like to do it manually in this case. Is there a simple way to perform this?
I tried setting the Model/property name of the Html.ValidationMessage helper to the input name but this didnt work:
@Html.TextBox("emailStr" )
@Html.ValidationMessage("emailStr","* Required")
Assuming you use default jQuery validation plugin, you can use Rules.Add method on client side for this
Also, do not forget to include
jquery.validate.min.js