java script not working until refresh the page
<p>My requirement is my text box should not accept the script tags(i.e &lt; and >). When I open the page first time my text box does not allow script tags(i.e &lt; and >).</p>

<p>After some time it allows only alphanumeric characters. When I refresh the page it works fine. Can any one help this. how can i get solution for this?  or is there any easy way for this.</p>

<p><strong>my code:</strong></p>

<p><code>&lt;input name="headerTextBoxs" id="headerTextBox" size="55" type="text" onKeypress="return keyRestricted(event)", onKeydown="return keyRestricted(event)" value=""  /&gt;</code></p>

<pre><code>&lt;script type="text/javascript"&gt;
    function keyRestricted(evt) {
        var theEvent = evt || window.event;
        var key = theEvent.keyCode || theEvent.which;

        var keychar = String.fromCharCode(key);
        //alert(keychar);
        var keycheck = /[a-zA-Z0-9]/;

        if ( (key == 60 || key == 62)) // not allowing script tags
        {

            if (!keycheck.test(keychar)) {
                theEvent.returnValue =false ; //for IE
                if (theEvent.preventDefault) theEvent.preventDefault(); //Firefox

            }
        }
    }

&lt;/script&gt;
</code></pre>

<p><strong>Another way:</strong>
My requirement is same that is not allow script tags(i.e &lt; and >). Here the problem is it works fine in mozilla firefox. but in google cromo and IE browsers my textbox not allowing backwards text  (i.e left arrow(&lt;-)).    simply i wrote like this.<br>
<strong>My code:</strong>    </p>

<p><code>&lt;input name="headerTextBoxs" id="headerTextBox" size="55" type="text" onkeyup = "this.value=this.value.replace(/[&lt;&gt;]/g,'');" /&gt;</code></p>
