zohab Posted January 5, 2010 Share Posted January 5, 2010 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> Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted January 5, 2010 Share Posted January 5, 2010 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> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.