Jump to content

count numbers of characters type in textarea


zohab

Recommended Posts

Hi,

 

In my project i have text area and when user type characters in text area then i want to count

the numbers of characters in text area type by user

 

example if i type "1234567890" then total char. count =10.

OR

 

text area will accept only 600 characters and when user type characters in text area then those will be subtracted from total 600 characters.

 

example if i write "1234567890" then it will show remaining count as 600-10=590

 

 

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<form action="" method="post" name="frm"><table width="100%" border="1" cellspacing="0" cellpadding="0">
  <tr>
    <td> </td>
    <td> </td>
  </tr>
  <tr>
    <td>Description</td>
    <td><label>
      <textarea name="textarea" cols="67"rows="6" ></textarea>
    </label></td>
  </tr>
  <tr>
    <td>Number of characters count </td>
    <td>10</td>
  </tr>
</table></form>

</body>
</html>

this code should help

 

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<form action="" method="post" name="frm"><table width="100%" border="1" cellspacing="0" cellpadding="0">
  <tr>
    <td> </td>
    <td> </td>
  </tr>
  <tr>
    <td>Description</td>
    <td><label>
      <textarea name="textarea" cols="67" rows="6" onkeyup="document.getElementById('char_count').innerHTML = this.value.length;document.getElementById('char_left').innerHTML = 600 - parseInt(this.value.length);"></textarea>
    </label></td>
  </tr>
  <tr>
    <td>Number of characters count </td>
    <td id="char_count">0</td>
  </tr>
  <tr>
    <td>Characters left</td>
    <td id="char_left">600</td>
  </tr>
</table></form>

</body>
</html>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.