I need to add a validation control in ASP MVC for a textbox. I used the @Html.ValidationMessage
helper.
There is one textbox and I want to show the error If the value is not entered in that field.
I used the following code.
@Html.TextBox("txtStudentNumber", "4234234");
@Html.ValidationMessage("txtStudentNumber", "Please enter the student number", new { @class = "text-danger" })
The above message is always shown irrespective if the textbox has a value or not.
I need to validate if the student textbox is empty and also when the save button is clicked.