I've got most of my javascript tucked away in a separate file and I've even got it using $.ajax to load supplementary scripts. So when I load up I check to see if I have a form I want to validate and trigger loadValidationScripts which holds what I need, loads then and then triggers a callback script. Problem is that my callback script is throwing errors on line 8 of the code below. I know it can find the form because it's already had to test the length Any ideas? $(function(){ if ($('#pwdResetForm').length > 0){ loadValidationScripts() } }); function pwdResetSetup(){ $("#pwdResetForm").validate(); }//pwdResetSetup function loadExtraJS(extras, callback){ var scriptname; for (var i=0; i<extras.length; i++) { scriptname = 'http://static.mysite.org./js/'+extras[i]; jQuery.ajax({ url: scriptname, dataType: "script", cache: true }).done(function() { setTimeout(callback+'()',3000); }); } } function loadValidationScripts(){ var extras = new Array(); extras[0] = 'validation/languages/jquery.validationEngine-en.js'; extras[1] = 'validation/jquery.validationEngine.js'; loadExtraJS(extras, 'pwdResetSetup'); } Code (markup): I've added the delay on the callback just in case it was a timing issue but it makes no odds. I'm still getting errors on $("#pwdResetForm").validate();
$("#pwdResetForm") is going to return the DOM object (the form itself). What exactly is the validate method you expect to be attached to that DOM object?
I'm working with the first example here: http://jqueryvalidation.org/documentation/ should be dead simple... I've used it before with no problems
That's a non-standard jQuery plug-in (one you need to include in your page). Quite possible I'm missing it, but I don't see your page including the validate.js file anywhere (and make sure it'a after jQuery itself loads).
Guess what?! If you follow the docs for one validation tool but install the scripts for another they don't ###### work. Who knew?
*SNICKER* I do that from time to time with Linsux installations. Every blasted distro is so different the instructions for one just won't work for another.