Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Javascript Javascriptexamples JavaScript Key Event

Related Tutorials


 
 

Share on Google+Share on Google+

JavaScript Key Event

Advertisement
This page discusses - JavaScript Key Event

JavaScript onkeyup Event

        

This section illustrates you the use of onkeyup event in JavaScript.

In the given example, we are going to show you how to display the text of textField1 on the text field2 on key up. For this purpose, we have created two text fields text1 and text2. On pressing the key to write the text on the textbox1, you will see that the same text will start displaying on the textbox2. This is possible by using the onkeyup event. It occurs when a keyboard key is released.

Following code copies the value of textbox 1 to textbox2:

document.form.text2.value = document.form.text1.value;

Here is the code:

<html>
<h2>TextBox shows Key Event</h2>
<script language="JavaScript">
function display() {
document.form.text2.value = document.form.text1.value;
}
</script>
<form name="form">
TextBox1: <input type="textbox" id="text1" onkeyup="display();"><br>
TextBox1: <input type="textbox" id="text2" >
</form>
</html>

Output will be displayed as:

Download Source Code:

        

Advertisements

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: April 18, 2011

Related Tutorials

Discuss: JavaScript Key Event  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:1
nerisa
August 18, 2011
math

nice....
DMCA.com