Answer the question
In order to leave comments, you need to log in
How to find parent class from input to display error message?
Good evening. How to solve such problem on JQ. There is a form for CMS MODX. After clicking on the "Submit request" button If the field is not correct, then ModX adds its error class to the input. How can I make it so that when the error class is added to the parent div tag, the error class is also added? It is necessary in order to display a text message under input that the user has entered something with an error. I'm not strong in JQ, I tried to do it through .parent (), but when ModX adds the error class to the input, the script simply does not see it, since it was loaded before the class appeared.
The form is standard.
<form class="ajax_form" action="" method="post">
<div><input type="text" class="text" placeholder="Имя*" name="yourname" id="yourname" value=""></div>
<div><input type="tel" class="text" placeholder="Телефон*" name="yourphone" id="yourphone" value=""></div>
<input type="submit" class="SubmitClose" value="оставить заявку">
</form>
<form class="ajax_form" action="" method="post">
<div><input type="text" class="text error" placeholder="Имя*" name="yourname" id="yourname" value=""></div>
<div><input type="tel" class="text" placeholder="Телефон*" name="yourphone" id="yourphone" value=""></div>
<input type="submit" class="SubmitClose" value="оставить заявку">
</form>
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