How to Textarea Limit Word Count With Jquery?

  HTML & CSS

following code use 

<!doctype html>
<html>
<head>
<meta charset=utf-8>
<title>textarea character limit</title>
</head>
<body>
<textarea maxlength=”50″ id=”text”>This textarea has a limit of 50 characters.</textarea>
</body>
</html>

css code: 

textarea {
width: 240px;
height: 80px;
padding: 5px;
}

Javascript :

function maxLength(el) {
if (!(‘maxLength’ in el)) {
var max = el.attributes.maxLength.value;
el.onkeypress = function () {
if (this.value.length >= max) return false;
};
}
}

maxLength(document.getElementById(“text”));

OR 

use the HTML code 

<textarea rows=”4″ cols=”50″ maxlength=”2″>
Enter text here…</textarea>

Spread the Code

2
Leave a Reply

avatar
1 Comment threads
1 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
2 Comment authors
codeerrorSoundarya CS Recent comment authors

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  Subscribe  
newest oldest most voted
Notify of
Soundarya CS
Member

We want words count not character count