Add an onchange event to your input element:
<input type="text" id="fName" value="" onchange="fName_Changed(this)" />
Javascript:
function fName_Changed(fName)
{
fName.style.borderColor = (fName.value != 'correct text') ? "#FF0000"; : fName.style.borderColor="";
}