Try this
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script>
function validateFun() {
debugger;
var txt = document.getElementById('txt1');
var value = txt.value.trim();
var itemsToValidate = [];
itemsToValidate.push('<&');
itemsToValidate.push('<!');
for (var i = 0; i < itemsToValidate.length; i++) {
if (value.startsWith(itemsToValidate[i])) {
alert('Your message');
return false;
}
}
return true;
}
</script>
</head>
<body>
<input type="text" id="txt1" value=" " />
<button onclick="return validateFun();">sub</button>
</body>
</html>