I'm trying to limit emoticons posted for comment message. It's easy for me to do that in PHP. But still can't find bugless function in javascript. Let's say I have an array of some emoticons codes, like ":sad:", etc. So everytime someone clicks over emot icon I wish to call javascript function to check if total number of emots code exceeded my limit. Then instead of putting code into textarea (have another good function for that) - display alert box if number exceeded limit. Sample how function should start... function check(object) { var limit=5; var content=document.getElementById(object).value; var smileys = new Array(':)',':)',':sad:',':mad:'); ....... how to retrieve number of smileys codes within content? } Code (markup):