Return to Snippet

Revision: 36417
at November 22, 2010 01:15 by kreamweb


Initial Code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Limit Number of Characters in a TextArea</title>
        <script type='text/javascript'
   src='http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js'></script>
    <script type='text/javascript'>
        $(document).ready(function() {
            $('#note').keyup(function() {
	            var max=140;
                var len = this.value.length;
                if (len >= max) {
                    this.value = this.value.substring(0, max);
                }
                $('#charLeft').text(max - len);
            });
        });
    </script>
</head>
<body>
<textarea id="note" cols="20" rows="8"></textarea><br/>
(Maximum characters: 140)<br/>
<span id="charLeft"> </span>  Characters left
</body>
</html>

Initial URL

                                

Initial Description

                                

Initial Title
Textarea limitazione caratteri

Initial Tags
jquery

Initial Language
JavaScript