155
rated 0 times
[
156]
[
1]
/ answers: 1 / hits: 81937
/ 13 Years ago, sun, march 13, 2011, 12:00:00
I have the following code, and I'm kind of stuck on what to do next. The idea is when you enter text into a text area a counter tells you how many characters you have left. Once you get to the max characters I want to stop allowing characters to be entered, or delete all the characters that were entered so there are only 10 characters in the text area. I know I have to put the code where it says alert(LONG);
but I'm not quite sure what.
var maxLen = 10;
console.log(Start);
$('#send-txt').keyup(function(){
var Length = $(#send-txt).val().length;
var AmountLeft = maxLen - Length;
$('#txt-length-left').html(AmountLeft);
if(Length >= maxLen){
alert(LONG);
}
});
More From » jquery