javascript - Calling onkeyup function only once -


i've written sample html page

<html> <head> <script> function validate() { alert(document.getelementbyid('newpass').value); } </script> </head>  <body> <input type="text" id="newpass" onkeyup="validate();" /> </body> </html> 

but in cases when press backspace, function getting called multiple times. how make execute once ?

all want current value of input box on event, onkeypress not giving current one, previous one. onkeyup gives current executing many times.

it sounds want current value of input field typing, want ignore if use backspace:

<html> <head> <script type="text/javascript"> function validate(that,e){   var eventobject = window.event? event : e;   var keycode = eventobject.charcode? eventobject.charcode : eventobject.keycode;   if (keycode != 8) {     alert(that.value);   } } </script> </head>  <body> <input type="text" id="newpass" onkeyup="validate(this,event);" /> </body> </html> 

Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -