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> Link to comment https://forums.phpfreaks.com/topic/187250-count-numbers-of-characters-type-in-textarea/ 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> Link to comment https://forums.phpfreaks.com/topic/187250-count-numbers-of-characters-type-in-textarea/#findComment-988835 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.