1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Playing with validation but getting Object [object Object] has no method 'validate' errors

Discussion in 'jQuery' started by sarahk, Apr 8, 2014.

  1. #1
    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.
    upload_2014-4-9_15-50-45.png

    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();
     
    sarahk, Apr 8, 2014 IP
  2. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,333
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #2
    $("#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?
     
    digitalpoint, Apr 8, 2014 IP
  3. sarahk

    sarahk iTamer Staff

    Messages:
    28,500
    Likes Received:
    4,460
    Best Answers:
    123
    Trophy Points:
    665
    #3
    sarahk, Apr 8, 2014 IP
  4. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,333
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #4
    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).
     
    digitalpoint, Apr 8, 2014 IP
  5. sarahk

    sarahk iTamer Staff

    Messages:
    28,500
    Likes Received:
    4,460
    Best Answers:
    123
    Trophy Points:
    665
    #5
    Guess what?!
    If you follow the docs for one validation tool but install the scripts for another they don't ###### work. Who knew? :)
     
    sarahk, Apr 11, 2014 IP
  6. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #6
    *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.
     
    deathshadow, Apr 12, 2014 IP