InStr(str, SearchForStr): Returns the location a character (charSearchFor) was found in the string str
InStr function written by: Steve Bamelis
InStr(strSearch, charSearchFor) : Returns the first location a substring (charSearchFor) found in the string strSearch. (If the character is not found, -1 is returned.)
Requires use of: Mid function :
http://www.expertsforge.com/Web-Development/Tutorial-86.asp
<script language="JavaScript">
function InStr(strSearch, charSearchFor)
{
for (i=0; i < strSearch.length; i++)
{
if (charSearchFor == Mid(strSearch, i, 1))
{
return i;
}
}
return -1;
}
</script>
Example:alert(InStr("Hello_World", "_"))
Output:5