In my webpage, I am dealing with client side validation failures displayed within divs. The text inside these divs can vary from one to another.
<div class="validation-failure">At least one of the above 2 fields needs to be entered</div>
Additionally, server side validation errors are shown as follows:
<div id="messages_product_error_view">
<ul>
<li>At least one of the above 2 fields needs to be entered</li> </ul>
</div>
I am looking for a way to display client side validation only when it matches the server side validation error. If the client side error is empty, then show the server side validation instead. Perhaps this can be achieved using jQuery - any guidance on this would be appreciated?
Hello there!
I am interested in detecting whenever text appears within a div element.
Here's the scenario:
When a user enters text into an input field, client side JavaScript displays validation error messages.
However, sometimes users manage to bypass or receive incorrect client side validation. In such cases, we have incorporated server side validation logic using PHP.
Currently, when a user types something in the input field, both client side and server side validations are triggered upon submitting the form.
I aim to exclusively display client side validation errors, falling back to server side validation only if no client side errors exist. Although the proposed solution works, continuous wrong input entries trigger repeating client side validation messages alongside persistent server side validation errors. Therefore, I need a method to detect when the user inputs text, showing client side validation first before resorting to server side validation.