Forums

Email field displays HTML code after Event Loop

brianvic 12 Jul, 2012
Hi

I have ChronoForm V4 and Joomla 1.5.23. My form is working great, but I found I was getting a lot of spam submissions.

In an effort to stop that I tried Captcha, but couldn't get the image to appear. So I decided to try ReCaptcha, which works great. Except for when an incorrect entry is attempted. The error is caught and the form refreshes, but the email field then contains:

 <script language='JavaScript' type='text/javascript'> <!-- var prefix = 'mailto:'; var suffix = ''; var attribs = ''; var path = 'hr' + 'ef' + '='; var addy60414 = 'brv' + '@'; addy60414 = addy60414 + 'me' + '.' + 'co' + '.' + 'uk'; document.write( '<a ' + path + '\'' + prefix + addy60414 + suffix + '\'' + attribs + '>' ); document.write( addy60414 ); document.write( '<\/a>' ); //--> </script><script language='JavaScript' 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 language='JavaScript' type='text/javascript'> <!-- document.write( '</' ); document.write( 'span>' ); //--> </script>


The email address is displayed perfectly before submission and if the submission is successful the email address is fine on the outgoing email. It is only when a failed submission happens that it no longer shows the address.

Any ideas how this can be fixed?

Cheers!
brianvic 12 Jul, 2012
Hi, Bob

Thanks for such a quick reply. That was what the problem was. My apologies. I thought I had searched the FAQ fully, but obviously not.

The error that gets shown for a failed ReCaptcha is at the top of the form. I have a long form so it means the user is taken away from the area with the error (it's down beside the submit button). Is it possible to set where the error box appears? Or even to have it appear at the bottom of the form instead of the top?

Thanks once again for your help.

Brian
GreyHead 12 Jul, 2012
Hi Brian,

I think that you can set a error message near the ReCaptcha input by adding a div like this (from the Show HTML action):

Display server side errors below fields, for this to work you need to have this code in the place you want the error to appear at:
<div id="error-message-FIELD_NAME_HERE"></div>


This won't turn the top error off though. You can do this by using the Show Top Errors setting on the Form General tab.

Bob
brianvic 13 Jul, 2012
Hi Bob

Thanks for that. It should have been obvious to me what that setting does, but I'd looked at it and passed over it.

Finally, where would I change/add code to jump to the error on a form after the form refreshes. In my case there will only be one area where an error will occur. I have a long form and at the moment when the form refreshes it returns to the top of the form and the error location will always be near the bottom of my form.

Perhaps being able to jump to something like an anchor point? But for that I'd need to know where I can hook into the code.

Thanks again for your help. It's much appreciated.

Brian
GreyHead 13 Jul, 2012
Hi Brian,

Here's some code that will put the focus back in the ReCaptcha. It assumes that you have the {ReCaptcha} tag in Custom Code element with the id=recaptcha
window.addEvent('domready', function() {
  var error = $$('#recaptcha_container_div div.error-message')[0];
  if ( error.get('html') !== '' ) {
    $('recaptcha_response_field').focus();
  }
});

Bob
This topic is locked and no more replies can be posted.