151
rated 0 times
[
152]
[
1]
/ answers: 1 / hits: 68640
/ 13 Years ago, tue, june 28, 2011, 12:00:00
Using jQuery I would like to:
- Limit the number of lines a user can enter in a textarea to a set number
- Have a line counter appear that updates number of lines as lines are entered
- Return key or n would count as line
$(document).ready(function(){
$('#countMe').keydown(function(event) {
// If number of lines is > X (specified by me) return false
// Count number of lines/update as user enters them turn red if over limit.
});
});
<form class="lineCount">
<textarea id="countMe" cols="30" rows="5"></textarea><br>
<input type="submit" value="Test Me">
</form>
<div class="theCount">Lines used = X (updates as lines entered)<div>
For this example lets say limit the number of lines allowed to 10.
More From » jquery