Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

jquery word limit in text area

Status
Not open for further replies.

GiddyRob

Programmer
Aug 25, 2005
37
GB
Hey,

I am trying to set the word limit for a text area. I am nearly there, but can't quite get it to work. I can get it to count down the words, but the maxlength field is still counting the words so if there is a limit of 200 words it stops allowing input at 200 characters. The message on the screen has the word count correct.

Could someone help me finish off this code so it works. I have stripped it out of my page so you can see it easily. You can test this code and it will work in a browser:

Code:
<script type="text/javascript" src="jquery/jquery.js"></script>
		<link type="text/css" href="jquery/smoothness/jquery-ui-1.8.1.custom.css" rel="stylesheet" />	
		<script type="text/javascript" src="jquery/jquery-1.4.2.min.js"></script> 
		<script type="text/javascript" src="jquery/jquery-ui-1.8.1.custom.min.js"></script>
		<script src="jquery/jquery.maxlength.js" type="text/javascript"></script> 
<script type="text/javascript">
	$(function() {
		$("#accordion").accordion({autoHeight: false });
	});
		$(function() {
		$("#tabs").tabs();
	});
	
	$(function(){
	$('textarea.wordLimited').maxlength({
	'words': true,
	'feedback': '.wordsLeft'
	});
	});
	
	//-->
	</script> 
<form>    
    <strong>Profile: </strong>(200 words maximum)<p> <strong>Words left:</strong> <span class="wordsLeft">200</span></p>
  <textarea maxlength="200" class="wordLimited" name="recom" style="border:1px solid #666666; width:655px; height:90px; margin:0px 0px 10px 0px; overflow:auto;"></textarea></form>

Thanks in advance :)

Cheers

Rob
 
but the maxlength field is still counting the words"

*"but the maxlength value is still counting the characters"

:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top