var SPECIAL_CHARS = Array("\x5B", "\x5C", "\x5D", "\x5E", "\x7B", "\x7C", "\x7D", "\x7E", 8364, 49792, 14844588, '�', '%', '/', '&','�','!','"','(',')','=','[','\\',']','^','{','|','}','~');
var dynamic_variables = Array("${nome}");
function charUsed(el) {
var base = el;
var count = base.val().length;
var chars = base.val().split("");
var numberOfSpecialChars = 0;
for (var k=0; k<chars.length; k++) {
if ($.inArray(chars[k], SPECIAL_CHARS) > -1) {
numberOfSpecialChars++;
}
}
if($.inArray(base.val(),dynamic_variables) != -1)
{
numberOfSpecialChars = numberOfSpecialChars+40;
}
return count + numberOfSpecialChars;
} // function
Basically, I need to count the textarea length and if this contains some special char (array SPECIAL_CHARS) count X 2 (till here, all goes right).
Now I need to add some other words (no more chars), like ${nome}
Pseudocode:
if an element of array is in base.val(), add 40 to the numberOf SpecialChars
Of course, my code doesn't function.