Hi

I am having trouble with some javascript code that checks the first 2 letters of what the user inputs and whether it equals a certain set of characters.

If the user for instance types in 'TT' in an input field, then i want the holding div to disappear, if anything else is typed in then this action wont happen. My code is below:

Code:
<script type="text/javascript">
function checkCode() {
	var x=document.forms["myform"]["code"].value.substring(0, 2);
	if (x == 'TT')
		document.getElementById('main').style.display = 'none';
	}
}
</script>

<div id="main">
<form name="myform" action="check-form.php" method="post">
    <table id="table" cellpadding="0" cellspacing="0">
        <tr>
        <td>Input</td>
        <td><input id="code" type="text" name="code" onkeyup="checkCode()" onchange="checkCode()" /></td><td><input type="submit" value="SEND"/></td>
        </tr>
    </table>
</form>
</div>
I believe the problem lies in the javascript line: "if (x == 'TT')", as the rest of the script responds but it just doesnt recognise whether 'x' starts with 'TT'

Any help would be greatly appreciated