Call Us Now at +1.403.536.9877 or fire us an email for a free quote

Add an email verification script on Joomla

Posted by Bruno
on 26 September 2014

This method has been tested on Joomla 2.5. It should work fine as well on Joomla 3.x.

Let's say you have a standard Joomla contact form with two email fields. The first one will be called "email", the second one "email verification". To create/add custom fields for your Joomla contact form, please check this quick tutorial.

 

You want to be sure your visitors submit an appropriate email address so it's important that those fields are being compared before the submission of the form. Let's take an example. Here's my custom contact form:

201409-custom-joomla-contact-form

Our contact form has the ID contact-form-cont.

The submission button has the class button.

First email input field has the ID jform_contact_email.

Second email input field has the ID jform_contact_email_verification.

The only thing you need to do is add this litttle JS script code in the index.php of your template, before the </head>. Path: templates/nameofmytemplate/index.php. Think of replacing the approriate variables with your own.

jQuery(document).ready(function($) {
					jQuery('#contact-form-cont .button').click(function($){
					//alert(45);
						var email = jQuery('#jform_contact_email').val();
						var email_c = jQuery('#jform_contact_email_verification').val();					
						if(email != email_c){ 
							alert("Emails do not match. Please check.");
							jQuery('#jform_contact_email_verification').addClass('invalid');
							return false;
						}
						
					});
			
			});

 

Leave your comments

Post comment as a guest

0 / 2000 Character restriction
Your text should be in between 20-2000 characters
terms and condition.
  • No comments found