Link to home
Start Free TrialLog in
Avatar of Bruce Gust
Bruce GustFlag for United States of America

asked on

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

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;
}

Open in new window


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?
ASKER CERTIFIED SOLUTION
Avatar of Pawan Kumar
Pawan Kumar
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Bruce Gust

ASKER

Hey, Pawan!

I just deleted this question not realizing you had responded. I'll give the points just as a way to say, "Thank you" for your time.

I was able to figure it out. What I was lacking was this: var usrEEID = document.getElementById("usrEEID").value...

The ".value" is what made all the difference.

Thanks for your help, though!
Pawan weighed in and I want to honor his time...
Thanks, friend!