It seems you are trying to get the input value FirstName. getElementById()returns only node. Instead, access its value:
var FirstName = document.getElementById('FirstName').value;
var CardMessage = document.getElementById('Message').value;
var aPosition = CardMessage.indexOf(FirstName);
if (aPosition === -1)
alert("Name Not In Message.");
}
Also, note that you have a mistake getElementByIdwith capital Dat the end, where it should be lowercase.
source
share