I'm using C# with MVC(Razor View Engine)

I'm doing validation using Annotation Like this:-

Model :-

public int VendorId { get; set; }

Razor view Engine :-

<div class="col-md-3">
 <label>@Html.LabelFor(r => Model.VendorId)</label>
 @Html.DropDownListFor(x => x.VendorId, new SelectList(suppliers, "Value""Text"),"-Select-", htmlAttributes: new { @class = "select-full" })

 @Html.ValidationMessageFor(x => x.VendorId, null, new { style = "color: red" })

and it was showing error message

The Vendor field is required.

if I'm not selecting vendor.

Now I want to highlight (Border Color in Red) of this Dropdown Field instead showing this message if validation failed (DataAnnotation) instead showing a message on both client & server side

Related posts

Recent Viewed