Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS JQuery validator not working in WordPress Re: JQuery validator not working in WordPress

#64876
clokey2k
Participant

I can see that maybe the data in contactengine.php is incorrect, the success/error pages at least (a localhost reference is still there).

As for the jquery validator you have jquery loaded twice, the second (more up-to-date version) loads after the validate plugin, and probably destroys the plugin.

I set all of my jquery scripts to load in my functions.php, then they will load in order. Maybe try this yourself, try the example below (filling in the file locations correctly :-) ):

if (!is_admin()) {
wp_deregister_script('jquery'); //Stop WordPress default jQuery
wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js', false, '1.3.2'); //Load Googles jQuery
wp_enqueue_script('jquery');

//Load jquery plugin
wp_register_script('jquery_validator','/path/to/js/jquery.validate.js', 'jquery', '1.0'); //'jquery' is passed as a reference so that this loads AFTER 'jquery'
wp_enqueue_script('jquery_validator');

//Load custom script
wp_register_script('custom','/path/to/js/page.js', 'jquery_validator', '1.0'); //'jquery_validator' is passed as a reference so that this loads AFTER the plugin
wp_enqueue_script('custom');
}

In theory they all get loaded in the correct order based on dependency, ‘jquery_validator’ depends on ‘jquery’.