Ваш "ввод" был таким?
<input value="<?php echo $errorMessage; ?>"/>
Я советую использовать атрибут placeholder,
<input placeholder="<?php echo $errorMessage; ?>"/>
или, если хотите, продолжать использовать JS,
var inputBox = document.getElementById(INPUT_BOX_ID);
inputBox.oninput = function(){
inputBox.value = inputBox.value.replace(" - Confrim valid surname",""); // Simply remove the Error Text you've echoed
inputBox.oninput = null; // Delete the function so user can type something
}
// Its still not detecting the valid surname, but its removes the " - Confrim valid surname"