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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:51:13+00:00 2026-05-25T10:51:13+00:00

A function called checkUsername executes when I focusout of a input box with the

  • 0

A function called “checkUsername” executes when I focusout of a input box with the id “regUsername”

$('#regUsername').focusout(function(){
    checkUsername();
});

The function:

function checkUsername(){
    var form_data = { username : $('#regUsername').val() };
    $.ajax({
        url: "/register/validateUsername",
        type: 'POST',
        data: form_data,
        success: function(msg) {
            var obj = $.parseJSON(msg);
        },
        error: function(data){
            dbdown();
        }
    });
}

Currently every time you focusout of the input box the ajax post function will run. This causes a slight flicker on returned validation box. I was wondering if it is possible to keep the last instance of the value which was passed in and then compare it with the new value passed in. If they are the same then there would be no need for an ajax post.

Any help on this would be much appreciated 🙂

  • 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-25T10:51:14+00:00Added an answer on May 25, 2026 at 10:51 am

    Store it, if different call ajax and set new ‘lastValue’

    var lastValue = "";
    function checkUsername(){
        var curr = $('#regUsername').val(),
            form_data = { username : curr };
        if (lastValue !== curr) {
          $.ajax({
            url: "/register/validateUsername",
            type: 'POST',
            data: form_data,
            success: function(msg) {
                var obj = $.parseJSON(msg);
            },
            error: function(data){
                dbdown();
            }
         });
         lastValue = curr;
       }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a javascript function called GetRequest() that calls the server with $.ajax() and
function ff_chk_username_unique(element, action) { alert(element.value); alert(action); var actiona=http://localhost/myproject/check/check_username.php; var form_data = { username: element.value,
So I have a function called submitEdit(): function submitEdit() { //var ffield = document.getElementById(form_eline);
PHP has a great function called htmlspecialcharacters() where you pass it a string and
I am testing a function called extractions that operates over any list. extractions ::
I have a function called FindSpecificRowValue that takes in a datatable and returns the
I have a function called: void initializeJSP(string Experiment) And in my MyJSP.h file I
I have a function called Colorbox (jQuery plugin) that takes a number of parameters
I have this function called ProperCase that takes a string, then converts the first
In Python there is a really neat function called zip which can be used

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.