Try this:
<html>
<head>
<script name=javascript>
function checkInput(inputText)
{
var error
error = "ok";
//use the following line if the input isnt case sensitive
//inputText = inputText.toUpperCase();
if (inputText.length > 0)
{
if (inputText.substr(0,3) != "DTP")
{
error = "There was an error.";
}
}
alert(error);
}
</script>
<title>Untitled Document</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<form name="form1" method="post" action="">
<input type="text" name="textfield" onBlur="checkInput(this.value)">
</form>
</body>
</html>