Use
@Html.ValidationMessageFor(m => m.Code)
to check the properties of the code. And the Property code should be defined as follows:
[Required]
public string Code{ get; set; }
and to set the value in the textbox code. You can install it in the controller as follows.
Model.Code="fffff";
and in view mode -
<td>@Html.TextBoxFor(m =>(m.Code), new { @Value = @Model.Code)</td>
@Html.ValidationMessageFor(m => m.Code)
Js i.e
<script src="/Scripts/jquery.validate.unobtrusive.js"></script>
<script src="/Scripts/jquery.validate.unobtrusive.min.js"></script>
: -