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>

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.