search() takes a regexp.
You want indexOf().

Nick

-----Original Message-----
From: Hays, Duncan [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, October 31, 2000 4:13 PM
To: CF-Talk
Subject: [OT] JavaScript str.search(".")


I'm trying to use JavaScript to validate an email address and I want to find
the position of the period (".") in the address. When I pass it a valid
address like:

        [EMAIL PROTECTED] ( = email)

and I have in my function:

var vat = email.search("@");
var vdot = email.search(".");

vat is equal to 4 and vdot is equal to 0 (zero)!

email.substr(0,1) gives me "d" as it should.

Why can't it give me the correct index of a period? Is there a way to test
for the ascii value?

Any help is MUCH appreciated.

Thanks,
Duncan Hays
Peace Corps


**********************************************************************
Information in this email is confidential and may be privileged.
It is intended for the addressee only. If you have received it in error,
please notify the sender immediately and delete it from your system. 
You should not otherwise copy it, retransmit it or use or disclose its
contents to anyone. 
Thank you for your co-operation.
**********************************************************************
------------------------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists or send a message 
with 'unsubscribe' in the body to [EMAIL PROTECTED]

Reply via email to