JavaScript Textarea Object : onchange Event handler

Description

The onchange event handler of textarea object is defined in a <textarea> and </textarea> (i.e. <textarea name="mytextarea" onchange = "JavascriptCode"> </textarea>). It executes some JavaScript code or function when a textarea object loses the input focus and its value has been modified since gaining focus.

Version

Implemented in JavaScript 1.0

Syntax

onchange = "JavascriptCode"

Parameter

JavascriptCode : JavaScript statement or JavaScript function.

Example of Textarea object : onchange event handler

In the following web document onchange event handler shows the effect when the textarea object loses the input focus and its value has been changed since gaining focus.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>JavaScript Textarea object's Event handler : onchange Example</title>
<script type="text/javascript">
function textchange()
{
alert("Content of Textarea box has changed...");
}
</script>
</head>
<body>
<h1 style="color: red">JavaScript Textarea object's Event handlers : onchange</h1>
<h3>If you edit the content of the textarea box and goes outside then onchange event
will occurred and an alert message will be displayed.</h3>
<hr />
<textarea name="TextArea" rows="5" cols="50" onchange ='textchange()'>
Here we are learning JavaScript onchange method of textarea object.
</textarea>
</body>
</html>

View the example of textarea object's onchange event handler in the browser

Practice textarea object's onchange event handler with Online Editor

Supported Browser

Internet Explorer 7 Firefox 3.6 Google Chrome 7 Safari 5.0.1 Opera 10
Yes Yes Yes Yes Yes

See also :

Javascript event handlers.

Javascript object's event handlers.

Please Google+, Like this tutorial on FaceBook, Tweet, save it as bookmark and subscribe with our Feed. Have suggestions? comment using Disqus down this page. Thanks.


share with delicious share with facebook w3r rss  share with digg share with reddit share with stumbleupon share with twitter