In this tutorial I will show you how to use jquery.maxlength.js on some common form fields
To start, you will need to download a copy of the jQuery library http://docs.jquery.com/Downloading_jQuery.
You will also have to download the plugin jquery.maxlength.js
When you have downloaded the copy you will need to include it in your file.
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
</head>
<body>
<!-- we will add our HTML content here -->
</body>
</html>
Next step is to include jquery.maxlength.js
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery.maxlength-min.js"></script>
</head>
<body>
<!-- we will add our HTML content here -->
</body>
</html>
Now to the fun part, how to apply the functionality to your script.
<script type="text/javascript">
$(document).ready(function(){
$('#textarea_1_1').maxlength();
});
</script>
<script type="text/javascript">
$(document).ready(function(){
$('div.example2 textarea').maxlength();
});
</script>
<script type="text/javascript">
$(document).ready(function(){
$('div.example3 textarea').maxlength();
$('#textarea_3_2').maxlength( {status: false, showAlert: true} );
});
</script>
<script type="text/javascript">
$(document).ready(function(){
$('div.example4 textarea').maxlength();
$('#textarea_4_1').maxlength( {events: ['blur']} );
});
</script>
<script type="text/javascript">
$(document).ready(function(){
$('div.example5 textarea, div.example5 input').maxlength( {slider: true} );
});
</script>