skywalker2909
skywalker2909

Reputation: 1686

ASP.NET MVC Validation change color from red to green on success

I have successfully implemented the validation for all my fields using the data annotations, but now what i want is that when the value entered in my field is valid , i want its color to change from Red which comes by default to green indicating it as a success.

Any idea on this..?

Upvotes: 0

Views: 4261

Answers (2)

AliRıza Adıyahşi
AliRıza Adıyahşi

Reputation: 15866

In your default css file there are following codes:

/* styles for validation helpers */
.field-validation-error
{
    color: #e80c4d;
    font-weight: bold;
}

.field-validation-valid
{
    display: none;
}

input.input-validation-error
{
    border: 1px solid #e80c4d;
}

input[type="checkbox"].input-validation-error
{
    border: 0 none;
}

.validation-summary-errors
{
    color: #e80c4d;
    font-weight: bold;
    font-size: 1.1em;
}

.validation-summary-valid
{
    display: none;
}

You can change where you want.

Upvotes: 3

Tomi Lammi
Tomi Lammi

Reputation: 2126

Jquery automatically adds valid class after you change the input from error to valid so simply add style for it

CSS:

input.valid
{
    border: 1px solid Green;
}

Upvotes: 5

Related Questions