| Javascript Text Box Characters Counter |
|
|
|
Forms always require validation when they are used in not safe environments. One method is to verify the data submitted through POST or GET before actually executing the form action. Using Javascript it is possible to do this in a more simple way. Here you have an example of how you can limit the number of characters an user can insert into a input or a textarea field. You can see here a running javascript count words script The right field keeps track of how many characters a user can still insert and the characters that overtake that limit are removed. The code explained: We create a javascript function that counts the number of remaining characters and trims the string if the length is bigger that the maximum allowed value. he form will contain an input field for the text and one for the remaining number of characters. he text input field will call the javascript function every time a up or down key event will arrise. See the code below: <SCRIPT LANGUAGE="JavaScript"> If you found this tutorial useful you might be interested to read the following: Installing Apache, PHP, MySQL on a Windows 98/2000/XP Computer
|

Text Box Characters Counter 
