Well I'm starting Bootstrap and I have a question about whether or not this is what I'm looking for. I have textarea
where it should limit the content to 300 characters it is already working:
$(function(){
$(".maxlength").keyup(function(event){
var target = $("#content-countdown");
var max = target.attr('title');
var len = $(this).val().length;
var remain = max - len;
if(len > max)
{
var val = $(this).val();
$(this).val(val.substr(0, max));
remain = 0;
}
target.html(remain);
});
});
Html:
Restam <span id="content-countdown" title="300">300</span>Caracteres)
<textarea name="texto" id="content" class="maxlength" maxlength="300" cols="60" rows="5"></textarea>
I just wish that instead of decreasing the number, the progress bar will increase as the text is being typed and if it reaches 100% (300 characters) it blocks any other digit. Any idea or simpler way to do this?