s4surbhi2218 Posted December 19, 2012 Share Posted December 19, 2012 Hi , I am making a program in which text goes when user types similar to facebook status update textbox the grey text goes away when user types i have used [code]<html><head><script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"> </script> <script> $("documnet").ready( function(){ $(document).keypress(function(event) { if (event.keyCode != 1 && event.keyCode != 2 && event.keyCode != 3) { $('input[type=text]').val(''); // alert('this is not mouse!'); } });</script></head><body><input type="text" id="txt" value="Surbhi"></body></html>[/code] but the problem is user is only able to type one alphabet in this. Any suggestions ??? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/272168-jquery-trigger-an-event-when-user-has-stopped-writing/ Share on other sites More sharing options...
codefossa Posted December 19, 2012 Share Posted December 19, 2012 Here's one way to do it off the top of my head. I set it to 750 milliseconds after you're done typing. Demo: http://xaotique.no-ip.org/tmp/32/ HTML <input type="text" id="type" /> <span id="status"></span> Javascript / jQuery // Allow page to load. $(document).ready(function() { // Set our timer global and give a timeout for stop typing. var timer, timeout = 750; // Just clearing anything the user has in the text field on load. $("#type").val(""); // Watch for the user to type in the text field. $("#type").keyup(function() { // Clear timer if it's set. if (typeof timer != undefined) clearTimeout(timer); // Set status to show we're typing. $("#status").html("Typing ...").css("color", "#009900"); // Set status to show we're done typing on a delay. timer = setTimeout(function() { $("#status").html("Stopped").css("color", "#990000"); }, timeout); }); }); Quote Link to comment https://forums.phpfreaks.com/topic/272168-jquery-trigger-an-event-when-user-has-stopped-writing/#findComment-1400409 Share on other sites More sharing options...
s4surbhi2218 Posted December 21, 2012 Author Share Posted December 21, 2012 Here's one way to do it off the top of my head. I set it to 750 milliseconds after you're done typing. Demo: http://xaotique.no-ip.org/tmp/32/ HTML <input type="text" id="type" /> <span id="status"></span> Javascript / jQuery // Allow page to load. $(document).ready(function() { // Set our timer global and give a timeout for stop typing. var timer, timeout = 750; // Just clearing anything the user has in the text field on load. $("#type").val(""); // Watch for the user to type in the text field. $("#type").keyup(function() { // Clear timer if it's set. if (typeof timer != undefined) clearTimeout(timer); // Set status to show we're typing. $("#status").html("Typing ...").css("color", "#009900"); // Set status to show we're done typing on a delay. timer = setTimeout(function() { $("#status").html("Stopped").css("color", "#990000"); }, timeout); }); }); Its pretty!!!! Quote Link to comment https://forums.phpfreaks.com/topic/272168-jquery-trigger-an-event-when-user-has-stopped-writing/#findComment-1400722 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.