Answer the question
In order to leave comments, you need to log in
jquery validation setting?
Hello!
Please help me deal with the situation.
On my website, I implemented field validation in mail forms through a special jquery plugin jquery validation. The installation of the plugin turned out to be quite simple, there were no problems with it.
The essence of the plugin is that if the field does not pass the test, then after the field a special label with the .error class appears , to which I can set any styles via css.
If the field passes validation, then the label is set to display:none and the input is set to the class . valid .
Actually the question is as follows: how to assign the class .valid not to input, but
one more label ?
thanks in advance!
Answer the question
In order to leave comments, you need to log in
Counter question:
Show the code if you want the error to be explained to you.
Of course you can do it like this
var form = $( "#myform" );
form.validate();
$( "button" ).click(function() {
$("input.valid").removeClass("valid");
$("label.need-class").addClass("valid");
});
And you have configured the form correctly. I myself used this plugin on my project, and it adds this class without any bicycles. If the form fails validation, it will
<label id="lastname-error" class="error" for="lastname">Введите не мение 3-х символов</label>
<label id="lastname-error" class="error valid" for="lastname">Готово!</label>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question