Javascript indexOf not working
<p>The following code looks for the name of a person in a message that they have entered using the indexOf method.</p>

<p>However it is returning the not present result even when the name is present. If I only Darren as the cardMessage it works.</p>

<p>Can anyone point out what is wrong.   </p>

<pre><code>&lt;%
firstName = "Darren"
cardMessage = "Is Darren in the message?"
cardMessage = CleanX(cardMessage)
firstName = UCase(firstName)
cardMessage = UCase(cardMessage)

Function CleanX(strString)
Set regEx = New RegExp
regEx.Pattern = "[^a-z0-9 ]+"
regEx.IgnoreCase = True
regEx.Global = True
CleanX = regEx.Replace(strString, "")
End Function
%&gt;
&lt;p&gt;&lt;%=cardMessage%&gt;&lt;/p&gt;
&lt;p&gt;&lt;%=firstName%&gt;&lt;/p&gt;
&lt;a href="javascript:check_message()"&gt;Click Here&lt;/a&gt;
&lt;script type="text/javascript"&gt;

s1 = new String("&lt;%=firstName%&gt;")
s2 = new String("&lt;%=cardMessage%&gt;")

function check_message()
{
var purchaser=s1;
var purchaser_ok=purchaser.indexOf(s2);
if (purchaser_ok==-1)
{ 
confirm('Name is NOT in message');
}
else
alert('Name is in message');
}
&lt;/script&gt;
</code></pre>
