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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:48:06+00:00 2026-05-23T18:48:06+00:00

I need some help with a JavaScript function that I call onKeyUp, it is

  • 0

I need some help with a JavaScript function that I call onKeyUp, it is a Ajax function but every time I write any character it calls the function and it slow the page performance and it check every time, it is an user check with the database.

I tried this:

 var timer;
 function chk_me(){

   clearTimeout(timer);
   timer=setTimeout(function validate(){...},1000);
}

But my validate function have a parameter so I am unable to pass it, I call the function like this:

<input type="text" name="usuario" id="usuario" class="required" onKeyUp="chk_me();" minlegth="4" value=/> 

Is it right? What should I do?

It is my first question and I hope that you all understand it

Thanks,
Alberto

Thank you all, since I am new I cant do it in a different answer so I edited my question with the solution.
I find this: http://bytes.com/topic/javascript/answers/451142-need-advice-acting-only-last-onkeyup-event-series and use the last answer method and add it some code, I leave you the code, like it say it isnt the best way but works so if you have some other way I will appreciate it and use it here it is:

var keyCount = 0;
var timeoutCount = 0;

function handleKeyUp() // keyup handler
{
keyCount++;
setTimeout("compareCounts()", 500);
}

function compareCounts()
{
var usuario = document.profileForm.usuario.value;
timeoutCount++;
if (keyCount == timeoutCount)
{
xajax_checaUsuario(usuario);
}
}

So I take the var in that way any suggestions to make it better?

Thanks

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

    Don’t pass validate directly to setTimeout, but rather call it from within an anonymous function:

    var timer;
    function chk_me(arg) {
        clearTimeout(timer);
        timer = setTimeout(function () {
            validate(arg);
        }, 1000);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm not that good at javascript (yet), so I need some help, with an
Need some help from javascript gurus. I have one page where http://www.google.com/finance/converter is embedded
Need some help assigning a mouseover event to display some icons that start out
I need some help calculating Pi. I am trying to write a python program
I need some help implementing the Radix sort algorthim in JavaScript. I found this
Once again I need some help. I'm working with a table that contains 3
I'm working with jQuery for the first time and need some help. I have
I need some help to get the ContentType of a file that is uploaded
i need some help here. I have a dialog box that contains an iFrame
I need to call a Javascript function from the server side in Client side.

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.