JavaScript: count minimal length of characters in text, ignoring special codes inside
- by ilnur777
I want to ignore counting the length of characters in the text if there are special codes inside in textarea. I mean not to count the special codes characters in the text. I use special codes to define inputing smileys in the text. I want to count only the length of the text ignoring special code.
Here is my approximate code I tried to write, but can't let it work:
// smileys
// =======
function smileys(){
var smile = new Array();
smile[0] = "[:rolleyes:]";
smile[1] = "[:D]";
smile[2] = "[:blink:]";
smile[3] = "[:unsure:]";
smile[4] = "[8)]";
smile[5] = "[:-x]";
return(smile);
}
// symbols length limitation
// =========================
function minSymbols(field){
var get_smile = smileys();
var text = field.value;
for(var i=0; i<get_smile.length; i++){
for(var j=0; j<(text.length); j++){
if(get_smile[i]==text[j]){
text = field.value.replace(get_smile[i],"");
}
}
}
if(text.length < 50){
document.getElementById("saveB").disabled=true;
} else {
document.getElementById("saveB").disabled=false;
}
}
How the script should be in order to let it work? Thank you!