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

  • Home
  • SEARCH
  • 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 5952781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:43:49+00:00 2026-05-22T17:43:49+00:00

This is using jQuery 1.6.1 and Validate 1.8.1. I have been banging my head

  • 0

This is using jQuery 1.6.1 and Validate 1.8.1.

I have been banging my head against a wall because of this problem, and now I’m trying the other approach to try and solve this problem. I need to query the database for existing usernames so that someone signing up doesn’t register the same one again.

HTML:

<form class="cmxform" action="register.php" method="post" name="signup" id="signup">
   <ul>
      <li>
        <label for="username">Username: <em>*</em></label>
        <input type="text" id="username" name="Username" size="20" class="required" placeholder="Username" />
      </li>
   </ul>
</form>

This time, I’m trying to use the remote function for the validate script:

    $("#signup").validate( {
        var username = $("#username").val();
        rules: {
            Username: {
                required: true,
                minlength: 5,
                remote: {
                    url: "dbquery.php",
                    type: "GET",
                    async: false,
                    data: "action=checkusername&username="+username,
                    success: function (output) {
                            return output;
                    }
                }
            }
        },
        messages: {
            Username: {
                required: "Enter a username",
                remote: jQuery.format("Sorry, {0} is not available")
            },
        },
        submitHandler: function(form) {
            form.submit();
        }
    });

The code in question that doesn’t work is var username = = $("#uname").val();. Firebug gives the error missing : after property id.

I’m including the mentioned variable above inside validate() because I only want the value of the input after I’ve typed something into it, not upon loading of the page.

The other problem I’ve been running into is making the remote error message ONLY show up when a username already exists in the database. Unfortunately, it shows up whether dbquery.php comes back as true or false. If I try an existing username, it returns false, then I rewrite a new username that returns true, the message doesn’t go away. Similarly, when I write a username and it returns true, I still get the remote error message.

What am I doing wrong?

  • 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-22T17:43:50+00:00Added an answer on May 22, 2026 at 5:43 pm

    As you can read How can I force jQuery Validate to check for duplicate username in database?

    The solution is to use the remote property:

    Example with remote:

    $("#signup").validate( {
        rules: {
            username: {
                required: true,
                minlength: 5,
                remote: {
                    url: "dbquery.php",
                    type: "get",
                    data: {
                        action: function () {
                            return "checkusername";
                        },
                        username: function() {
                            var username = $("#username").val();
                            return username;
                        }
                    }
                }
            }
        },
        messages: {
            username: {
                required: "Enter a username"
            }
        },
        submitHandler: function(form) {
            form.submit();
        }
    });
    

    To set a custom error message your PHP file must return the message instead of false, so echo "Sorry, this user name is not available" in your PHP file.

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

Sidebar

Related Questions

I have this strange issue with my web app. You see, I'm using jQuery
I'm using JQuery and Prototype in this web application that I'm developing. I'm looking
I've got this textBox which triggers off an ajax request using jQuery: <asp:TextBox ID=postcodeTextBox
I'd like to do something like this to tick a checkbox using jQuery :
I need to change an element's ID using jQuery. Apparently these don't work: jQuery(this).prev(li).attr(id)=newid
New to javascript/jquery and having a hard time with using this or $(this) to
I can't tell if this is a result of the jQuery I'm using, but
I am currently testing this in Mozilla FireFox 3.0.5 using FireBug 1.3.0 with jQuery
hope you can help me on this one, I'm currently using this: jQuery plugin:validation
I'm using JQuery from Google CDN and I've been getting stack overflow error (using

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.