|
|
If you were looking out for a script to count the number of words in a TextArea, then here it is:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Count Words in a TextArea</title>
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js">
</script>
<script type="text/javascript">
$(function() {
$("#btnCount").click(function() {
var strText = jQuery.trim($('#txtArea').val());
alert('Total No of Words are: ' + strText.split(/\s+/).length);
});
});
</script>
</head>
<body>
<div>
<textarea id="txtArea" cols="20" rows="10">
</textarea>
<br />
<input id="btnCount" type="button" value="Count Words" />
</div>
</body>
</html>
OUTPUT
See a Live Demo
'Like' us on our FaceBook page if you find this blog useful. Thanks!
Did you like this post?
|
|
|
||
|
|
|
|
Save on Delicious |
|
|
subscribe via rss |
|
subscribe via e-mail |
|
|
print this post |
|
follow me on twitter |




comments
0 Responses to "Count the Number of Words in a TextArea using jQuery"Post a Comment