want to match only whole words in javascript for error
<p>So I am trying to create a little form validation on entering a Name
I want to not allow certain characters, already created names, and internally reserved words. The problem is say when I want to put "posts" in a name it says that it is matching "pos" and fails.</p>

<pre><code>var badchar = new Array('"', "," , "'" , "#", "&amp;", "!", "@", "$", "+", ";", ":", "*", "(",")", "[","]","{","}", "/", "=" );
    var resword = new Array("positive","pos","negative","neg","neutral", "neu","twitter","itunes","facebook","android","forums","RSS Feeds");

    var existingNames = @anames;
    var valueLen = $("#aname").val().length;
    var fail=false;

    var filterElem = $('#aname');
    var filterName = $('#aname').val();

    $.each(badchar, function(char){
        if ( filterName.indexOf(badchar[char]) != -1 ) {
            console.log("bad character")
            filterElem.css('border','2px solid red');
            window.alert("You can not include '" + badchar[char] + "' in your Filter Name");
            fail = true;
        }
    });

    $.each(resword,function(){
        if ( filterName.match(this)) {
                console.log("bad word");
                filterElem.css('border','2px solid red');
                window.alert("You can not include '" + this + "' in your Filter Name");
                fail = true;
            }
    });
</code></pre>
