Javascript indexOf

It seems like you are trying to get the value of the input FirstName. getElementById() only returns the node itself. Instead access its value:

var FirstName = document.getElementById('FirstName').value;
var CardMessage = document.getElementById('Message').value;

// Then use the variable `FirstName` instead of the quoted string
var aPosition = CardMessage.indexOf(FirstName);

// Best practice would be to use === for strict type comarison here...
if (aPosition === -1)
  alert("Name Not In Message.");
}

Also, note that you've misspelled getElementById, with a capital D at the end where it should be lowercase.

Tags:

Javascript