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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:45:25+00:00 2026-06-11T10:45:25+00:00

There is a textbox which is associated with an onkeyup event listener (a JavaScript

  • 0

There is a textbox which is associated with an onkeyup event listener (a JavaScript function, say that alerts something). For an example-

<input type='text' name='text1' onkeyup='exec(this.value);'/>
<script>
exec = function(textdata) { alert(textdata); }
</script>

In this case the alert message will come each time the user hits something on the keyboard.

Is there any way of even handling, where in the event handler will proceed only after a few seconds of inactivity. that is, in this case the alert message will come only if the user
has done typing a long text, and is thinking if he wants to add something more or not. For example, he types in his first name and waits for 2 second and after that the alert message appears, and alert message does not appears while he types in each letter of his first name.

  • 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-11T10:45:26+00:00Added an answer on June 11, 2026 at 10:45 am

    You need to use onkeyup rather than onchange if you wish to run a function every time a key is pressed. Try this for the functionality you want

    <input type='text' name='text1' onkeyup='exec(this.value);'/>
    <script>
    
    var timer; //This needs to be a global variable
    
    exec = function(textData){
    
      clearTimeout(timer);
    
      timer = setTimeout(function(){ alert(textData) }, 2000);  
    }
    </script>
    

    Every time the user presses a key (enters a character into the textbox) the function is called and the timer is cleared. The timer is then set to alert the textbox’s value after 2 seconds, if they again press any keys before the 2 seconds has elapsed the timer is reset. Here is a working jsFiddle.

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

Sidebar

Related Questions

In below link there is add button which allows you to ADD multiple textbox
There are a button and a textbox. I added a KeyDown event to textbox
Is there a way to hide the textbox that is targeted by the colorpickerextender
How can I create an TextBox in WPF ( With XAML ) that there
I want to let TextBox control TextChanged event fire only when there are more
I have a textbox which i echo data from mysql. However if there is
I have an input text which (asp textbox) which is using the jquery ui
In .Net, there is the MaskedTextBox and there is the TextBox which has an
I have a textbox which has the code; <input type=text maxlength=5 size=2 value=1 id=paging_textbox>
Im designing a dialerPad form using Windows form, there is a textbox which should

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.