Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Using Javascript to confirm email address?

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 05-01-2004, 02:09 AM
 
xcell67 xcell67 is offline
 

Senior Member
  
Join Date: Dec 2003
Posts: 149
 

Default Using Javascript to confirm email address?

In order to cut back on mistyped email addresses and customers complaining about not receiving an order confirmation because they didn't type their email correctly, I was thinking about having an added filed to the registration.

Email Address and the new: Confirm Email address

I was trying to see if I could implement the other java validations already there, ie zipcode validation but that didn't seem to work. How does the password and confirm password validation work? I couldn't find any java code for it.

Thanks for reading, I think this is a much needed feature.
Reply With Quote
  #2  
Old 05-01-2004, 07:39 AM
  adpboss's Avatar 
adpboss adpboss is offline
 

X-Man
  
Join Date: Feb 2003
Location: Ontario, Canada
Posts: 2,389
 

Default

This is a problem in every store, specifically for someone like me who deals with adolescent boys and young men. People who cannot be bothered to type their name, address or email properly.

This would be a nice feature.
Reply With Quote
  #3  
Old 05-21-2004, 07:34 PM
 
xcell67 xcell67 is offline
 

Senior Member
  
Join Date: Dec 2003
Posts: 149
 

Default

I created a new field "email2" and tried adding this code to include/register.php

Code:
function validate($email, $email2, ==) { if($email == $email2) { return true; } else { return false; } }

but then i got a page error when trying to use register on the customer side, I think i have to try to implement it into register.tpl rather than register.php, anyone know how to make the above code smarty friendly?

thanks
Reply With Quote
  #4  
Old 05-21-2004, 08:55 PM
 
Mod King Mod King is offline
 

Senior Member
  
Join Date: May 2004
Posts: 115
 

Default

You could do some javascript regex checking before they submit the form

But i am not sure on your intetions, did you want to make it so that they enter 2 e-mail addresses and you compare them?

If so you have to add both fields to register.tpl

Then you *should* be able to use them in register.php
if you have any problems just bug me
i'm around alot.
__________________
Mod King
Reply With Quote
  #5  
Old 05-21-2004, 09:19 PM
  B00MER's Avatar 
B00MER B00MER is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Keller, TX (Cart-Lab.com)
Posts: 3,165
 

Default

First edit skin1/check_email_script.tpl, replace its entire contents with:

Code:
{* $Id: check_email_script.tpl,v 1.6.2.2 2004/03/26 09:47:33 svowl Exp $ *} {literal} <script language="JavaScript1.2"> function checkEmailAddress(field) { var goodEmail = field.value.search(/^[A-Za-z0-9]{1}([A-Za-z0-9_\-\.]+)[^\.]\@[^\.]([A-Za-z0-9_\-\.]+\.)+[A-Za-z]{2,6}[ ]*$/gi); if (goodEmail!=-1) { if(field.value==document.registerform.emailtwo.value) { return true; } else { alert("Email's do not match, please correct!"); document.registerform.emailtwo.focus(); document.registerform.emailtwo.select(); return false; } } else { {/literal} alert("{$lng.txt_email_invalid|replace:"\n":" "|replace:"\r":" "}"); {literal} field.focus(); field.select(); return false; } } </script> {/literal}

Now open up skin1/main/register_contact_info.tpl and underneath the email table row (</tr>) add this:

Code:
<tr valign=middle> <td align=right>Validate {$lng.lbl_email}</td> <td><font class=Star>*</font></td> <td nowrap> <input type=text name=emailtwo size=32 maxlength=128 value="{$userinfo.email}"> </td> </tr>

This way your not inserting two emails into the database but rather making sure the user has entered the same values into the email field incase of misstypes. All javascript based.

Above code was written with 3.5.x
__________________
Cart-Lab - 100+ Social Bookmarks for X-Cart.
Reply With Quote
  #6  
Old 05-23-2004, 08:12 PM
 
xcell67 xcell67 is offline
 

Senior Member
  
Join Date: Dec 2003
Posts: 149
 

Default

works like a charm,

THANK YOUUUUUUUUUU BOOOMER!
Reply With Quote
  #7  
Old 05-23-2004, 08:16 PM
  adpboss's Avatar 
adpboss adpboss is offline
 

X-Man
  
Join Date: Feb 2003
Location: Ontario, Canada
Posts: 2,389
 

Default

Should be standard in X-Cart. RRF are you awake right now?
Reply With Quote
  #8  
Old 05-25-2004, 08:53 PM
 
xcell67 xcell67 is offline
 

Senior Member
  
Join Date: Dec 2003
Posts: 149
 

Default

Ah, this was the culprit! After a day of modding I wasn't able to test the gift certificate purchase. I finally found out that this javascript although very effective for validating the email during checkout and register (thank you Boomer) does not allow a gift cert to be purchased. I tried to see if other functions that require email such as contact us had the same problem but it was only gift certificates.

Boomer, Could you modify the java code to exclude its effect on giftcerts or could you tell me what I would have to add to giftcert.tpl for it to work properly?

Thanks
Reply With Quote
  #9  
Old 05-26-2004, 07:42 AM
  B00MER's Avatar 
B00MER B00MER is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Keller, TX (Cart-Lab.com)
Posts: 3,165
 

Default

Duplicate the original skin1/check_email_script.tpl and rename it for the modified one and change the include in the register tpl
__________________
Cart-Lab - 100+ Social Bookmarks for X-Cart.
Reply With Quote
  #10  
Old 05-26-2004, 09:28 AM
 
Loon Loon is offline
 

Member
  
Join Date: Feb 2004
Location: MN, USA
Posts: 19
 

Default

For a little more explicite directions, for those of us "code challenged", along with the two code updates above from Boomer (call them step 1 and step 2), do this to make the gift certificate email validation operational also:

Step 3: create a new file called [cart directory]/skin1/check_gcemail_script.tpl with contents:

Code:
{* $Id: check_gcemail_script.tpl,v 1.6.2.2 2004/03/26 09:47:33 svowl Exp $ *} {literal} <script language="JavaScript1.2"> function checkGCEmailAddress(field) { var goodEmail = field.value.search(/^[A-Za-z0-9]{1}([A-Za-z0-9_\-\.]+)[^\.]\@[^\.]([A-Za-z0-9_\-\.]+\.)+[A-Za-z]{2,6}[ ]*$/gi); if (goodEmail!=-1) { if(field.value==document.gccreate.emailtwo.value) { return true; } else { alert("Email's do not match, please correct!"); document.gccreate.emailtwo.focus(); document.gccreate.emailtwo.select(); return false; } } else { {/literal} alert("{$lng.txt_email_invalid|replace:"\n":" "|replace:"\r":" "}"); {literal} field.focus(); field.select(); return false; } } </script> {/literal}

Step 4: in the file [cart directory]/skin1/modules/Gift_Certificates/giftcert.tpl
changed include on line 3 to call my new file for giftcert email validation:
replace:
Code:
{include file="check_email_script.tpl"}
with:
Code:
{include file="check_gcemail_script.tpl"}

around line 29, to call the new function created in Step 3 above:
replace:
Code:
if ((document.gccreate.send_via[0].checked) && (!checkEmailAddress(document.gccreate.recipient_email)))
with:
Code:
if ((document.gccreate.send_via[0].checked) && (!checkGCEmailAddress(document.gccreate.recipient_email)))

around line 203, ADD the second email field to the gift certificate purchase form, with a few changes from the one in the registration form:

Code:
<tr> <td nowrap align=right>Validate {$lng.lbl_email}</td> <td><font class=Star>*</font></td> <td nowrap> <input type=text name=emailtwo size=32 maxlength=128 value="{$giftcert.recipient_email}"> </td> </tr>

Please Note that I have not thoroughly tested everything. The contact us form still works fine, gift cert purchase works fine, registration (thanks Boomer) works fine. Please post here if you find other problems.

Jean
__________________
Linux / Apache 1.3.31
PHP 4.3.3
MySQL 4.0.18
X-Cart 3.5.4 in production Mar 08, 2004
X-Cart 3.5.4 Win2k SP4 for development
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 11:59 PM.

   

 
X-Cart forums © 2001-2020