Hi,
I’ve used the jQuery validation plugin (http://jqueryvalidation.org/) by either adding a “required” class on the field or by writing out specific fields in the validate function.
I have a new challenge that I don’t know how to solve. Due to third party systems, the "required"class is being added in the parent
I’ve never used jqueryvalidation, but what you could do is scan for any non-form field that has “.required” and apply the class to all children elements through jQuery. So before doing the .validate() method, add this:
Hi labofoz, so I copied and pasted your snippet in the <head> of my doc, as I have the validate script at the bottom of the page but it does not add a required class on the input. Any ideas why?
This finds any input or textarea within li.required and adds “required” to it. The one I posted before only checks immediate children which might not work in all cases. If it doesn’t work would you mind posting a link?
Here is a link to the stripped down version of the page as it has some information that should not be live yet. Basically I stripped out content and kept the form to one field as it should be a quick test. http://conradabraham.com/clients/me/validation/
Thanks for your help!
I added that script through the console and it worked fine. Make sure the scripts are loaded at the bottom of the page, or at least after the list items. If that’s not possible, try wrapping the script like this:
// Wait until the entire page is loaded
jQuery(function($){
$('li.required').find('input, textarea').addClass('required')
})