Answer the question
In order to leave comments, you need to log in
How to style label after Validation Jquery?
Good afternoon, please help me to style the label after Validation Jquery check.
Through css, I set the label color to red on error, but when the error is removed, the color of the label does not change to the previous one, but remains red. The question is how to change the color of the label back to black?
Any options are possible.
<form action="#" class="feedback-form" id="feedbackForm">
<div class="feedback-field">
<input required name="userName" id="userName" type="text" class="feedback-form__input">
<label for="userName" class="feedback-form__label">Nombre</label>
</div>
<div class="feedback-field">
<input required name="userPhone" id="userPhone" type="tel" class="feedback-form__input">
<label for="userPhone" class="feedback-form__label">Teléfono móvil</label>
</div>
<div class="feedback-field">
<input required name="userEmail" id="userEmail" type="email" class="feedback-form__input">
<label for="userEmail" class="feedback-form__label">E-mail</label>
</div>
<button type="submit" class="button feedback-form__button">Enviar la solicitud</button>
</form>
.invalid + label {
color: #ff8080;
}
$("#feedbackForm").validate({
errorElement: "div",
errorClass: "invalid",
rules: {
userName: {
required: true,
minlength: 2,
},
userPhone: {
required: true,
minlength: 11,
},
userEmail: {
required: true,
minlength: 1,
},
},
messages: {
userName: "Longitud mínima 11 carácteres",
userPhone: "Longitud mínima 11 carácteres",
userEmail: "Longitud mínima 11 carácteres",
}
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question