troubleshooting Question

Why am I being told that "indexOf" is not a function?

Avatar of Bruce Gust
Bruce GustFlag for United States of America asked on
jQuery
4 Comments1 Solution69 ViewsLast Modified:
Here's my code:

function validateForm() {
	var dob = document.getElementById("usrDOB");
	var usrEEID = document.getElementById("usrEEID");
	var error = '';
	if(usrEEID.indexOf("S")==-1)
	{
		$('#usrEEID').css('border', 'solid 2px red').focus();
		error = "Make sure you include a capital \"S\" in the Employee ID field!";
	}
	if (!isValidDate(dob.value)) 
	{
		$('#usrDOB').css('border', 'solid 2px red').focus();
		error = "Date of Birth must be in the format XX/XX/XXXX\n\r";
	} 
	else 
	{
		$('#usrDOB').css('border', '');
	}
	
	if (error.length > 0) {
		alert(error);
		return false;
	}
	return true;
}

Everything works except...

if(usrEEID.indexOf("S")==-1)
      {
            $('#usrEEID').css('border', 'solid 2px red').focus();
            error = "Make sure you include a capital \"S\" in the Employee ID field!";
      }

I keep getting an error that says "usrEEID.indexOf is not a function." What am I doing wrong?
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 4 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros