sKunKbad Posted August 15, 2007 Share Posted August 15, 2007 I have a form that I validate using ajax. When a form field is valid, an image changes from green to red so the user knows they have filled out the form field correctly. The problem is, if they type fast, I think it's hanging or lagging. For special reasons each form field is validated with the onKeyUp event handler. Does anyone have suggestions as to how to make a user typing fast not cause the validation to lag. Perhaps some sort of timer that only allows the validation to take place once per second? How could I do this? Quote Link to comment https://forums.phpfreaks.com/topic/65092-onkeyup-lag/ Share on other sites More sharing options...
sayedsohail Posted August 15, 2007 Share Posted August 15, 2007 This should solve the mystery, but make sure browser can't handle multiple ajax requests simentenously. var timer = null; var delay = 1000; function startTimer(a,b,c) { window.clearTimeout(timer); timer=window.setTimeout('MyAjaxRequest("'+a+'","'+b+'","'+c+'")',delay); } Quote Link to comment https://forums.phpfreaks.com/topic/65092-onkeyup-lag/#findComment-325148 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.