SitePoint Sponsor |
|
User Tag List
Results 1 to 5 of 5
-
Jun 18, 2002, 15:36 #1
Javascript toLowerCase for comparing email addresses
I'm using the following script to compare two email addresses to make sure that they are the same. I want to ignore differences that are simply down to the visitor using capital letters in one field and lowercase in the second. I'm guessing the 'toLowerCase' (or 'toUpperCase') before the comparison is the way to do this, however, I've not been successful in getting this to work.
Can anyone advise where to incorporate the case change in the script?
PHP Code:function emailCheck(enquiryForm) {
if (enquiryForm._008_email2.value != enquiryForm._008_email.value) {
alert("The e-mail addresses that you entered do not match. Please amend. Thank you");
enquiryForm._008_email.focus(); return false;}
}
-
Jun 18, 2002, 15:53 #2
- Join Date
- Oct 2001
- Location
- Tucson, Arizona
- Posts
- 1,858
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Simple enough.
Code:function emailCheck() { if (enquiryForm._008_email2.value.toLowerCase() != enquiryForm._008_email.value.toLowerCase()) { alert("The e-mail addresses that you entered do not match. Please amend. Thank you."); enquiryForm._008_email.focus(); return false; } return true; }
-
Jun 18, 2002, 16:00 #3
I tried this, however, the script continued to detect the difference between "D" and "d" (which is what I am using to test).
Any idea where else the flaw may lie?
Thanks
Elf
-
Jun 19, 2002, 02:53 #4
- Join Date
- Jan 2001
- Location
- Lawrence, Kansas
- Posts
- 2,066
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I never understood the reason for using a form that asks for the user's email address twice - I ALWAYS copy and paste it from the first field to the second one, as I imagine most people would. Asking for a password twice makes perfect sense (the user can't see what they're typing) but if you want to validate an email address the only reliable way is to send a message to the address specified containing further details for signup.
-
Jun 19, 2002, 10:38 #5
I agree with what your saying and I also copy & paste in these situations, however, I plan to make the check an optional one for those people that are less than confident about their keyboard skills and want the context sensitive "spellcheck".
Elf
Bookmarks