Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8272551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T07:09:30+00:00 2026-06-08T07:09:30+00:00

I am making a form validation function and have the following code for it

  • 0

I am making a form validation function and have the following code for it

(function ( $ ) {
    $.fn.validate_thing = function (success_call_back) {
        var call_back = true;
        debugger;
        if (!this.is('form')) {
            return false;
        }

        $('input.empty').each(function() {
            if(!$(this).text()) {
                alert($(this).attr('name'));
                call_back = false;
            }
        });
    }
})(jQuery);

The problem is that when the page loads I get a javascript error saying that ‘object is not a function’ on the (jQuery) line. If I step through this with the debugger I don’t get this problem. If I put this in a document ready function I don’t get this problem. I’m thinking that it might have something to do with jQuery not being loaded with this script is run, but I include the jQuery library before the library that contains this code, not to mention if I don’t do this in a closure, i.e. do this

$.fn.validate_thing = function (success_call_back) {
    var call_back = true;
    debugger;
    if (!this.is('form')) {
        return false;
    }

    $('input.empty').each(function() {
        if(!$(this).text()) {
            alert($(this).attr('name'));
            call_back = false;
        }
    });
}

it works.

So I have a few work arounds for this problem but I’d still like to know why this is happening. Thanks in advance.

here’s what i have before it in the javascript page

engine = new function() {
this.request = function ( params ) {
    var data = params.data ? params.data : '';

    if (params.url) {
        var url = params.url;
        var page = document.URL.split('/').pop();
        var page = page.split('.')[0];
        data += 'content_page='+page+'.tpl';
    }
    else {
        var url = document.URL;
    }

    debugger;
    if (params.action) {
        data += data ? '&action='+params.action : "action="+params.action;
    }

    $.ajax({
        url : url,
        type : 'POST',
        data : data,
        dataType: 'json',
        success : function(data) {
            debugger;
            if (data && data.partials) {
                for (var key in data.partials) {
                    var element = data.partials[key];
                    $('#'+element.partial_name).replaceWith(element.partial_content);
                }
            }
        },
        error : function (jqXHR, textStatus, errorThrown) {
            debugger;

            alert('ajax error: '+errorThrown);
        }
    }).success(params.success);
}
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T07:09:33+00:00Added an answer on June 8, 2026 at 7:09 am

    If you get an error in the last line, it is likely that JavaScript interprets the parenthesis ( function() { ... } ) as function call of whatever precedes the code. This can happen if you forgot a semicolon in the previous line.

    Consider this:

    var foo = {};
    var bar = foo
    (function() {
    
    }());
    

    Note that the semicolon is missing after foo and therefore JavaScript interprets the code as foo(...), which throws the error

    object is not a function

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Alright, so I'm making a form validation everything is good in this JS, but
Can anyone tell me whats wrong with this code, im validating a form making
I'm making a signup form in which i've used following function for validate signup
I've been making this login form in C# and I wanted to 'submit' all
I have the following code that checks for both the username and password but
Im making a form validation and im creating a dom dynamically but when I
I'm making a form that I'm using the amazing JQuery validation plugin for (
I am making form validation and when user doesn't fill one of required fields
I am making a generic text validation function with jQuery. I made the function
I'm making a form and would like the code to execute only if the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.