Thursday, January 12, 2012

Counting Number of Words !!

Source Code For Counting Number of Words in A Text using Javascript.



<div dir="ltr" style="text-align: left;" trbidi="on">
<form method="POST" name="Pru">
<script language="JavaScript">
function countit()
{
var formcontent=document.Pru.Prucount2.value
var trimmed =formcontent.replace(/^\s+|\s+$/g, '') ;
var str = trimmed.replace(/ +(?= )/g,'');
trimmed=str.split(" ")
document.Pru.Prucount3.value=trimmed.length
}
</script><br />



<table border="0" cellpadding="0" cellspacing="0"><tbody>
<tr>       <td width="100%"><textarea cols="60" name="Prucount2" rows="12" wrap="virtual"></textarea></td>     </tr>
<tr>     
 <td width="100%"><div align="right">
<input onclick="countit()" type="button" value="Calculate Words" />
 <input name="Prucount3" size="20" type="text" /><br />
<div align="center">
<br />
<br />


No comments:

Post a Comment