
I am using MVC 3 validation. My Product Manager wants the label for each control that has an error to turn red.
So ‘Student First Name’ label should turn red. ‘Email address’ label should turn red.
I tried to wrap each error msg in a div and check the length of each div
<div id="divValStudentFirstName">@Html.ValidationMessageFor(m => m.studentFirstName)</div>
in a js file:
$(document).ready(function () {
if ($("#divValStudentFirstName").length > 1) {
("#divStudentFirstName").css("color", "red");
}
But I have no success. The validation check is done without a complete refresh and as a result, my $(document).ready isn’t fired when validation hits.
Client side validation disabled :
EDIT
Client side validation enabled
I’m really not a king in js, but this seems to work (well on a simple case at least)