Page 1 of 1

[How-To] Contact Form - Confirm Email Field Added

Posted: Sat Aug 13, 2011 5:08 am
by aaron1988
Hi everyone i thought i would post that i have added a new field called Confirm Email so if they put an email in Email field but they put the wrong email in confirm email it will say something like "Doesnt Match" i am using Jquery for this :).

EDIT: OOPS forgot to add attachments :) so here they are at bottomof post

Also i have only tested this on OC 1.5.1.1 but i believe should work on all the 1.5 releases or even below but it hasnt been tested so you could download something called Winmerge and compare the files to see if matches or what changes need to be made.

So here we go :)

Step 1: EDIT: catalog/controller/information/contact.php

Find:

Code: Select all

$this->data['entry_email'] = $this->language->get('entry_email');
then

Add After:

Code: Select all

$this->data['entry_confirm_email'] = $this->language->get('entry_confirm_email');
Then find:

Code: Select all

if (isset($this->error['email'])) {
         $this->data['error_email'] = $this->error['email'];
      } else {
         $this->data['error_email'] = '';
      }  
Add After:

Code: Select all

if (isset($this->error['confirm_email'])) {
         $this->data['error_confirm_email'] = $this->error['confirm_email'];
      } else {
         $this->data['error_confirm_email'] = '';
      }  
Find:

Code: Select all

if (isset($this->request->post['email'])) {
         $this->data['email'] = $this->request->post['email'];
      } else {
         $this->data['email'] = '';
      }
Add After:

Code: Select all

if (isset($this->request->post['confirm_email'])) {
         $this->data['confirm_email'] = $this->request->post['confirm_email'];
      } else {
         $this->data['confirm_email'] = '';
      } 
Find:

Code: Select all

if (!preg_match('/^[^\@]+@.*\.[a-z]{2,6}$/i', $this->request->post['email'])) {
            $this->error['email'] = $this->language->get('error_email');
       }
Add After:

Code: Select all

if (!preg_match('/^[^\@]+@.*\.[a-z]{2,6}$/i', $this->request->post['confirm_email'])) {
            $this->error['confirm_email'] = $this->language->get('error_confirm_email');
       }
	    if ($this->request->post['confirm_email']!=$this->request->post['email']) {
            $this->error['confirm_email'] = $this->language->get('error_format_confirm_email');
       }
Now Edit: catalog/language/english/information/contact.php

Find:

Code: Select all

$_['text_email']     = 'E-Mail:';
Add After: $_['text_confirm_email'] = 'Confirm E-Mail:';

Find:

Code: Select all

$_['entry_email']    = 'E-Mail Address:<span class="required">*</span>';
Add After:

Code: Select all

$_['entry_confirm_email']    = 'Confirm E-Mail Address:<span class="required">*</span>';
Find:

Code: Select all

$_['error_email']    = 'E-Mail Address not in valid format!';
Add After:

Code: Select all

$_['error_confirm_email'] = 'E-mail Address not in valid format!';
$_['error_format_confirm_email'] = 'E-mail Address does not match!';
Edit: catalog/view/theme/default/template/information/contact.tpl

Find:

Code: Select all

<b><?php echo $entry_email; ?></b><br />
Replace with:

Code: Select all

<label for="email"><?php echo $entry_email; ?></label><br />
Find:

Code: Select all

<input name="email" type="text" value="<?php echo $email; ?>" />
add id to it so looks like:

Code: Select all

<input id="email" name="email" type="text" value="<?php echo $email; ?>" />
Add After:

Code: Select all

<span id="emailInfo">Valid E-mail please, you will need it to progress</span>
Find:

Code: Select all

<?php if ($error_email) { ?>
    <span class="error"><?php echo $error_email; ?></span>
    <?php } ?>
    <br />
Add After:

Code: Select all

<label for="confirm_email"><?php echo $entry_confirm_email; ?></label><br />
    <input id="confirm_email" name="confirm_email" type="text" value="<?php echo $confirm_email; ?>" />
    <span id="confirm_emailInfo">Confirm Email Address</span>
    <br />
    <?php if ($error_confirm_email) { ?>
    <span class="error"><?php echo $error_confirm_email; ?></span>
    <?php } ?>
Find:

Code: Select all

<?php echo $content_bottom; ?></div>
Add After:

Code: Select all

<script type="text/javascript" src="catalog/view/javascript/jquery.js"></script>	
<script type="text/javascript" src="catalog/view/javascript/validation.js"></script>
Please find attached the two .js files and upload them to catalog/view/javascript/ also the file validation.js as all the information into it to add all the the same sort of styles for Name, Enquiry and even adding Subject and Phone. all you do is repeat the above steps but change to subject or phone etc. If you want me to post a full tutorial on adding all these please ask :)

If this doesn't work for you please let me know :)

EDIT: i will also try and post a VQmod of this so its easier and quicker for people just need to get used to it first lol

Kind Regards,
Aaron

Re: [How-To] Contact Form - Confirm Email Field Added

Posted: Fri Oct 14, 2011 3:25 pm
by Jeremy Fisk
Heia Aaron,

Thanks for the great post...

I have had a go at puting it into a vqmod, but please check this out... it isn't working for some reason... i'm pretty new to vQmod so i have probabily stuffed it up... but have a look anyway...

Thanks Dude

O0 O0

Jem

Re: [How-To] Contact Form - Confirm Email Field Added

Posted: Fri Oct 14, 2011 10:27 pm
by uksitebuilder
Test my vqmod Generator out if you want

http://1513.designs.org.uk/vqgen/vqgen.php

Re: [How-To] Contact Form - Confirm Email Field Added

Posted: Sat Oct 15, 2011 4:19 pm
by aaron1988
Hi Jem,

Try Simons vQmod Generator :).

and if that doesnt work then i will take a further look :).

Kind Regards,
Aaron

Re: [How-To] Contact Form - Confirm Email Field Added

Posted: Sat Oct 15, 2011 5:13 pm
by Jeremy Fisk
Hiya Aaron...

Thanks for your reply
Try Simons vQmod Generator :).
I have... see attached

Please note that i am trying on 1.5.0.2 and 1.4.9.5

Good luck

Jemz

Re: [How-To] Contact Form - Confirm Email Field Added

Posted: Wed Nov 23, 2011 10:42 am
by spirit
It didn't work for me in 1.5.1.3 :/
Any help?

Re: [How-To] Contact Form - Confirm Email Field Added

Posted: Fri Nov 25, 2011 5:11 am
by aaron1988
Hi ok :) i will look in the next few days when not at work lol

Thanks
Aaron

Re: [How-To] Contact Form - Confirm Email Field Added

Posted: Fri Nov 25, 2011 6:15 am
by spirit
aaron1988 wrote:Hi ok :) i will look in the next few days when not at work lol

Thanks
Aaron
Thanks man!
I think that OC team need add this function officially because is very very useful :)

Re: [How-To] Contact Form - Confirm Email Field Added

Posted: Tue Nov 29, 2011 8:41 am
by spirit
Don't forget it :)

Re: [How-To] Contact Form - Confirm Email Field Added

Posted: Mon Dec 12, 2011 7:29 pm
by spirit
Somebody can help in this way?
It's very useful, no doubt :)

Re: [How-To] Contact Form - Confirm Email Field Added

Posted: Wed Jan 11, 2012 12:11 am
by remcofaasse
Hi,
I'm also interested in vqmod for v 1.5.1.3.
Is this available? Thanks for the reply. Kind regards, Remco

Re: [How-To] Contact Form - Confirm Email Field Added

Posted: Thu Jan 26, 2012 8:49 pm
by Klimskady
Another vote for this for 1.5.1.3 as I have tried another similar to this but it didn't work so this would be great if it did..

Re: [How-To] Contact Form - Confirm Email Field Added

Posted: Tue Feb 07, 2012 8:51 am
by khalilm
Hi Everyone,

I saw the requests to have this functionality in 1.5.1.3 and thought it was a good idea so I added it to my code and would like to share with the community.

However, I have added it to Simon's "Better Contact Form" (BCF) which I believe is a must have to prevent spamming. You can find his code here:

http://forum.opencart.com/viewtopic.php?f=131&t=35286

I have been using BCF (2.0 with editable inputs) for a while, so I don't know if I have the latest version, but I have clearly marked my modifications in the code so if needed the changes could be copied.

If you find any errors, please post here and I will fix them. I will pass my changes along to Simon to see if he can add it in his code.

Hope this helps,
Khalil

Re: [How-To] Contact Form - Confirm Email Field Added

Posted: Sun Mar 04, 2012 3:44 am
by matte2k
Does this fix work with 1.4.9.5 ?