I’m trying to creating a little JavaScript Textcount which will include Maxarea.
Here is my JS:
function maxlength(item, max){
var a = $('#'+item+'').val();
var q = eval(""+a+".length");
var l = q - max
var msg = "Sorry but the max is "+max+", You have entered "+q+" characters into the textarea. Please delete at least "+l+" characters."
if (q > max){
$('#limit').html(msg);
}
}
With that this is the HTML:
<textarea id="area" onkeyup="maxlength('area', 12)"></textarea>
<br><br>
<div id="limit"></div>
The Problem is that the limit is not showing.
You need to lose the eval,
var q = eval(""+a+".length");, and replace with this:a is already a string with a
lengthproperty.Example