prettyComments, a solution to comment boxes

by: Stéphane Caron

Here's my solution to comment boxes that are alway too small for long comment. As the user enter comment in this box, the box will stretch so the full comment will always be visible, making it easier for the user to review and edit his comment before posting it.

If you have any comment or ways to improve it, just leave me a comment!

Below you can se a demo of it in action.

Demo

Browser support

This plugin has been tested and is known to work in the following browsers

Copyright

This script is licensed under Creative Commons Attribution 2.5. So you can use it in all you projects even commercial ones. Donations are always welcome.

Download

Uncompressed version (Script: 2.7kb)

Compressed version (Script: 1.8kb)

Version history

How to use

Nothing is easier to use. First include the jQuery library then include the prettyComments javascript in the head of the page(s) where you want to use prettyComments.
jQuery can be download here

				
<script src="js/jquery.js" type="text/javascript" charset="utf-8"></script>
<script src="js/prettyComments.js" type="text/javascript" charset="utf-8"></script>
				
			

Then you need to initalize prettyComments.

				
<script type="text/javascript" charset="utf-8">
	$(document).ready(function(){
		$('textarea').prettyComments();
	});
</script>
				
			

If you want prettyComments to be initialized on specific textareas, you can specify which element by using a CSS selector, like so:

				
<script type="text/javascript" charset="utf-8">
	$(document).ready(function(){
		$('#textarea1,.classOnTextarea2').prettyComments();
	});
</script>
				
			

You can also specify settings for the plugin, those are:

To specify the settings you want to uses for each of you textarea, you need to initialize the plugin like so:

				
<script type="text/javascript" charset="utf-8">
	$(document).ready(function(){
		$('#textarea1').prettyComments();
		$('.classOnTextarea2').prettyComments({animate: true, maxHeight:100});
	});
</script>
				
			

That's it, now your teaxtareas should behave the same as in the demo on this page

Support

If you need support, you can leave a comment in the main prettyComments post.

Donations

I spent a big amount of time to develop/support this script. You liked it? Feel free to donate!

© Stéphane Caron 2008