This is a part of my view
@model bhavin.Models.Employee
@using (Html.BeginForm("BuynowForm", "Home"))
{
<div class="form-group">
<label>Billing Address</label>
@Html.TextBox("bill_address", null, new { @class = "form-control valid" })
</div>
<p>
<input type="submit" value="Submit" class="btn btn-primary" />
</p>
}
I want to add required validation to it. The billing_address textbox is not a part of the models.employee. I am using mvc5 So how to add the validator?
@Html.TextBox("bill_address", null, new { @class = "form-control valid", @data_val = "true", @data_val_required = "Billing Address is required" }). Do not forget to add unobtrusive and validate JS files.@Html.ValidationSummary()Can I post this as an answer?