I want to use custom form validation for my input fields. I want to display a custom message and make borders red of input fields. The problem is that I am unable to do this in jQuery. For Html, I have found the following solution.
<form:input id="valid-to" required="required" type="text" class="custom-html-validation"
oninvalid="this.setCustomValidity('Enter User Name Here')"
oninput="this.setCustomValidity('')"/>
This oninvalid does work correctly and displays message when user submits the form.
How can I use similar functionality in jQuery. I have tried the solution from jQuery validation: change default error message but it did not resolve my problem and I got Cannot read properties of undefined (reading 'messages') in browser console.
Cannot read properties of undefinedmeans that you made a critical mistake with how you constructed your methods, called your methods, or included your scripts. Misspelling a rule or calling a rule that does not exist can cause this error. Since you have not shown us how you came to this error, there is no way anyone could help you solve it. Show us the working example of your code that reproduces the error.