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 7580979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:05:05+00:00 2026-05-30T18:05:05+00:00

I’m building a login form that will validate the login against a database, then

  • 0

I’m building a login form that will validate the login against a database, then if successful pass the user to a secure page.

I have verified that my SQL is correct and based on the examples that I borrowed code from, my submit form should be correct also. In fact, the sample code works properly on my server, which suggests a DOM error. This is a stripped-down version of what I’m running:

<script type="text/javascript" src="inc/jquery-1.7.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
jQuery.noConflict();
jQuery(document).ready(function() {
    jQuery("#login_form").submit(function() {
        jQuery("#msgbox").removeClass()
                         .addClass('messagebox')
                         .text('verifying')
                         .fadeIn(1000);

        jQuery.post("inc/ajax_login.php", {
            user_name: $('#username').val(),
            password: $('#password').val()
        }, function(data) {
            if (data == 'yes') { /* ... */
            }
            else { /* ... */
            }
        });
        return false;
    });
});​
</script>

The form runs thus, some lines further down the page:

<form action="" id="login_form" method="POST">
  <input type="text"     name="username" id="username" value="username" />
  <input type="password" name="password" id="password" value="password" /><br />
  <input type="hidden"   name="homeDir"  id="homeDir"  value=""         /> <span id="msgbox"></span> <br />
  <input type="submit"   name="Submit"    id="submit"    value="ENTER" class="submit"/>
</form>

However, JS throws an error saying “Uncaught TypeError: Cannot call method ‘val’ of null.”

I’m missing something here. Given that .post is not called until the form is submitted (and the error does not trigger until the form is submitted), why would val() be called against a null value? The form would be populated by then.

Also, I’m living on a PHP4.4.9 server. To the best of my understanding this is not a JSON call (therefore PHP5), but I’ll freely admit I’m in over my head here. Webdev was a past life for me and was never my strong suit.

  • 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-05-30T18:05:06+00:00Added an answer on May 30, 2026 at 6:05 pm

    You were trying to call val() on a non-jquery object. When you use jQuery.noConflict mode ‘$’ will be undefined. Try wrapping your jquery code like this…

    See jQuery.noConflict doc – http://api.jquery.com/jQuery.noConflict/
    Various methods to use jQuery.noConflict – http://zenverse.net/jquery-how-to-fix-the-is-not-a-function-error-using-noconflict/

    <script>
    
    jQuery.noConflict();
    
    (function($) { 
        $("#login_form").submit(function()
        {
            $("#msgbox").removeClass().addClass('messagebox').text('verifying').fadeIn(1000);
    
            $.post("inc/ajax_login.php", {
                user_name: $('#username').val(),
                password: $('#password').val()
            }, function(data) {
              if(data=='yes') {/* ... */}
              else {/* ... */}
            });
    
            return false;
        });
    })(jQuery);
    
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
We're building an app, our first using Rails 3, and we're having to build

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.