Forums

email check in V4

Dougj 01 Dec, 2011
I am building my first form using V4. Must say I am not a fan of this new format...

I have worked my way through most of my issues but am not having any luck with email verification. I have two fields I am trying to compare and verify. They are both email input fields and I want to compare them to see that they match. In the old J1.5 version of chronoforms I used a javascript that was pasted into the form code tab/form javascript window. It compared the two fields named emailaddress and emailaddress2 in the form.
function checkEmail(theForm) {
  if (document.getElementById('emailaddress').value !=   document.getElementById('emailaddress2').value)
  {
  alert('Your email address entries do not match! Please try again'); 
  return false;
  } 
  else {
    return true; 
  } 
}

That code does not seem to work in V4 after I paste it into the Load JS action, and I am having difficulty understanding how to use the emai verification elements built into V4.

Is there an easier method to do this?

Any guidance would be appreciated


Thanks D.
GreyHead 01 Dec, 2011
Hi Dougj,

I had a little dig around and found what appears to be a simple solution to this. In the second email input box add validate['confirm:emailaddress1'] to the Class box. This then triggers a validation message that matches the other messages.

[attachment=0]01-12-2011 11-01-15.png[/attachment]
[attachment=1]01-12-2011 11-04-19.png[/attachment]

ChronoForms v4 uses the FormCheck validation library in place of the LiveValidation library used in V3. However, the code snippet you posted is generic JavaScrip and should work with any form provided that the inputs have appropriate ids and 'theForm' is defined to match the form in use.

Bob
Dougj 01 Dec, 2011
Thanks so much Bob. That sems to have resolved the issue.

One quick question. Within the input field for emailaddress1 there was already a class set to
class=" validate['required','email']"

to force the user to actually enter something in that box.

Can I somehow combine the two class actions, because now the following is occurring.

Your solution is working, assuming the user actually enters anything in emailaddress2 filed. If however they leave that field blank, I get the follwoing code in the emailaddress1 field on Submit. I have no idea where this code comes from?

<script type='text/javascript'> <!-- var prefix = 'ma' + 'il' + 'to'; var path = 'hr' + 'ef' + '='; var addy42746 = 'djordan' + '@'; addy42746 = addy42746 + 'rog' + '.' + 'com'; document.write('<a ' + path + '\'' + prefix + ':' + addy42746 + '\'>'); document.write(addy42746); document.write('<\/a>'); //-->\n </script><script type='text/javascript'> <!-- document.write('<span style=\'display: none;\'>'); //--> </script>This e-mail address is being protected from spambots. You need JavaScript enabled to view it. <script type='text/javascript'> <!-- document.write('</'); document.write('span>'); //--> </script>

After this the reset does not clear the form and the page must be reloaded to clear all field and start over.

Thanks D.
GreyHead 02 Dec, 2011
Hi Doug,

As far as I could see from the FormCheck validation code if the first email input is required then having the confirm validation added will also make that input required.

The script you see is because you have the Joomla! Email Cloaking Plug-in enabled and it is trying to cloak the sample e-mail in the ChronoForms validation message. Disable the plug-in temporarily to check this is the problem. If you need the plug-in change the plug-ins order so that Email Cloaking runs before ChronoForms.

NB These are Joomla! plug-ins that you manage from Site Admin | Extensions | Plug-in Manager

Bob
colemjosel 29 Jun, 2012
Hi

I do this form with javascript to clean the value on click
[attachment=0]chrono.jpg[/attachment]

But i need to validate the value not can be the same for example:

The value of Full name must be diffrent to Full name

Regards
GreyHead 30 Jun, 2012
Hi colemjosel,

Your JavaScript needs to check the input value when the form is submitted (and before the validation runs) and remove any inputs that are set to their default 'label' values.

I have a tutorial that you can buy for a few dollars here that includes the code to do this in CFv3 and CFv4. See the CFv3 demonstration here.

Bob
melvins138 10 Sep, 2013
Does this work on multipage forms?

I have a six page form, I have a field on page 3 with a field name of "input_text_name".

Then on page 6, I have a confirmation box where the user needs to type in the same name as on page 3, that field name is "input_text_name_verify"

I placed the validate['confirm:input_text_name'] in the Field Class of input_text_name_verify, but it doesn't seem to work.

Is there code I need to place in the Events section under Load JS or does the validation happen natively?

Is this limited to inputs that are on the same page?

Thanks in advance for the help.
This topic is locked and no more replies can be posted.

VPS & Email Hosting 20% discount
hostinger