Forums

[Solved] Recaptcha and JS problems

d_folken 27 Apr, 2011
hi,
I recently installed for the first time chronoforms v4 rc1.8, my version of joomla is 1.5.23, 1.2.5 mootools, RocketTheme template, I managed to configure some features (mail, db, lightbox), but there are some that just do not go, they are not very practical for JS and PHP :? .. but I arrange me!
- I would put a limit of characters in the textarea but I can not integrate the javascript. I have read various tutorials and posts (http://greyhead.net/chronoforms/adding-a-character-counter-to-a-textarea) but refer to previous versions of CF and when I insert the code "load JS" seems not to be interpreted 😟
I tried several scripts running but when I insert them in CF stop working .... perhaps I should connect to an external JS file, but I do not know how ...
- I'm trying to get "Recaptcha" and after following your advice, now I view images
<div class="form_item">
<div class="cf_captcha">
<span>{ReCaptcha}</span>
</div>
<div class="cfclear">Β </div>
</div>

.. but I'm always the message "The reCAPTCHA Was Entered Correctly. Please try it again."
Also try to activate the "debug" but I do not know how to do it! 😲
- I am trying to connect CF to an external CSS file but the problem is always the same, I do not know what code to enter and where!
If I have to study, I'd rather start from CF V4, but I need simple code to start working on v4, waiting to come out a tutorial for V4...
Could you help me! 😢

ps: I apologize for my English..πŸ™„
d_folken 27 Apr, 2011
Could you help GreyHead
I would like to avoid installing the v3.2 😒
please!!!!
GreyHead 28 Apr, 2011
Hi d_folken,

I've been away for a day. I'll take a look when I've caught up on the posts and some other stuff.

Bob
Max_admin 29 Apr, 2011
Hi d_folken,

Please show us a screenshot for the "Events" tab in your form wizard

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
d_folken 29 Apr, 2011
hi Max,
sorry for the delay πŸ™„

Event tab:
[attachment=0]1.jpg[/attachment]

HTML code:
<div class="formstl">
<div class="ccms_form_element cfdiv_text" id="nome_e_cognome_container_div"><label for="nome">Nome e Cognome</label><input id="nome" maxlength="36" size="40" class="prova validate['required','alpha']" title="Inserire Nome e Cognome" type="text" value="" name="nome" />
<div class="clear"></div><div id="error-message-nome"></div></div>

<div class="ccms_form_element cfdiv_text" id="e_m_il_container_div"><label for="mail">E-M@il</label><input id="mail" maxlength="36" size="40" class="testo validate['required','email']" title="Inserire una mail valida" type="text" value="" name="mail" />
<div class="clear"></div><div id="error-message-mail"></div></div>

<div class="ccms_form_element cfdiv_textarea" id="messaggio_container_div"><label class="cf_label" style="width: 150px;">Messaggio:<br /><br />50 chars max<br /><span id='counter'>50</span> chars left</label><textarea id="messaggio" cols="36" rows="7" class="testo validate['required']" title="Inserire il messaggio" type="textarea" name="Messaggio"></textarea>
<div class="small-message"><a target="_blank" href="index2.php?option=com_content&view=article&id=386">Privacy - Informativa e Consenso</a></div><div class="clear"></div><div id="error-message-messaggio"></div></div>

<div class="ccms_form_element cfdiv_checkbox" id="presto_il_consenso_container_div"><input value="1" id="privacy" title="Accettare la Privacy" type="checkbox" class="validate['required'] label_right" name="privacy" />
<label for="privacy" class="full_label">Presto il consenso</label><div class="clear"></div><div id="error-message-privacy"></div></div>

<div class="form_item">
<div class="cf_captcha" style="padding-left: 150px;">
<span>{ReCaptcha}</span></div>
<div class="cfclear">Β </div></div>

<div class="ccms_form_element cfdiv_submit" id="input_submit_10_container_div"><input name="input_submit_10" class="invia" value="" type="submit" />
<div class="clear"></div><div id="error-message-input_submit_10"></div></div>
</div>


..firefox reports this error
Errore: $("text_0") is null
File sorgente: http://www.amsitaly.com/index2.php?option=com_content&view=article&id=396:contatti&catid=13
Riga: 47) 😟

JS code:
window.addEvent('load', function() {
    $('text_0').addEvent('keyup', function() {
	max_chars = 50;
	current_value = $('text_0').value;
	current_length = current_value.length;
	remaining_chars = max_chars - current_length;
		if ( remaining_chars <= 5 ) {
		   $('text_0').setStyle('background-color', '#F88');    		
		   $('text_0').value = $('text_0').value.substring(0, max_chars-1);
			if ( remaining_chars <= 0 ) {
			remaining_chars = 0;
			}
		} else {
		  $('text_0').setStyle('background-color', 'white');
		}
	$('counter').innerHTML = remaining_chars;
    });
});


link form:
http://www.amsitaly.com/index2.php?option=com_content&view=article&id=396:contatti&catid=13

Thanks, d_folken πŸ™‚
Max_admin 01 May, 2011
Hi d_folken,

First the JS error is because you don't have an element in that page has the id "text_0" and so this is expected!

I can't figure out why the ReCaptcha generates an error every time, did you check the ReCaptcha FAQs on their website ? they may have some info, because it should work fine, it's not something with Chronoforms I think.

You may also try the Core Captcha ?

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
d_folken 02 May, 2011
Max thanks for the tips! I was doing some testing ... πŸ™„
The Core Captcha is the first thing I tried when I installed CF4 and it works! πŸ˜€
I tried various plugins Recaptcha and no error, but give error in CF even if the code is practically the same! I do not understand! πŸ™„ 😟 😲
What is the correct HTML code to invoke the Recaptcha on CF4? 😟
I have read various FAQs Recaptcha, but still nothing! I'm trying to enable debug mode, but still I could not! :?

Also with regard to the JS code to restrict the characters in the Textarea, CF4 work out but not in the form! contactor character stays still, it seems that the HTML tag is not seen! 😟 😲
Perhaps I'm wrong here how to insert the JS script, I do not understand! :?

I have no idea ... I keep trying until I can! 😟 😲 :? πŸ™„
Thanks d_folken πŸ™‚
GreyHead 03 May, 2011
Hi d_folken,

To use ReCaptcha in CFv4:[list=a]
  • Add {ReCaptcha} to your Form HTML. Use a Custom Element to do this with {ReCaptcha} in the Code box.

  • Add a Load ReCaptcha action into the On Load event box

  • Add a Check ReCaptcha action into the OnSubmit event box and drag it to be the first event in the box

  • Add an Event Loop action to the pink OnFail event on the Check ReCaptcha action.

  • Save the form and check that the ReCaptcha is working OK.
  • [/list:o]

    As far as I can see you have done all this correctly. It may be that there are JavaScript errors from some other problem that stop the ReCaptcha loading its scripts correctly.

    I'll take a look at the counter code later.

    Bob
    GreyHead 03 May, 2011
    Hi d_folken,

    For the counter code you need to replace text_0 with the id of your textarea which is messaggio:
    window.addEvent('domready', function() {
      $('messaggio').addEvent('keyup', function() {
        max_chars = 50;
        current_value = $('messaggio').value;
        current_length = current_value.length;
        remaining_chars = max_chars - current_length;
        if ( remaining_chars <= 5 ) {
          $('messaggio').setStyle('background-color', '#F88');          
          $('messaggio').value = $('messaggio').value.substring(0, max_chars-1);
          if ( remaining_chars <= 0 ) {
            remaining_chars = 0;
          }
        } else {
          $('messaggio').setStyle('background-color', 'white');
        }
        $('counter').innerHTML = remaining_chars;
      });
    });
    d_folken 03 May, 2011
    Hi Bob,
    many thanks for the tip! πŸ˜€ πŸ˜€
    I misread the part of the guide that says:

    ".....We will need to know the ID of the text area; by default it will be text_0, the same as the element name........"


    ooooops!!! 😲 πŸ™„
    I try to better control the reCAPTCHA code ... also because I noticed that IE8 does not signal the error, even if there is, while FF is! :?
    But it is strange that the other plugin Recaptcha work well! 😈
    Thanks again for your help, I hope to find out what's wrong ... do you know :wink:
    Thanks d_folken πŸ™‚
    Max_admin 10 May, 2011
    Hi d_folken,

    Just tested your form and looks like the reCaptcha works, tested on google chrome!πŸ™‚

    Regards,
    Max
    Max, ChronoForms developer
    ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
    ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
    d_folken 13 May, 2011
    Hi max,
    yes, now everything works well on IE and FF! πŸ˜€
    I made ​​some mistakes of inexperience and carelessness! πŸ™„ :?
    After you enable debugging I noticed there was an error in the "private key " (one character was wrong !! 😈 )... then solved! πŸ™‚
    Then another error "incorrect-captcha-sol " but it was caused others reCaptcha plugin installed that were in conflict with the reCaptcha of CF! :wink:
    The "character counter to a textarea" I have resolved with the help of Bob!! πŸ˜€
    I had some problems with receiving mail but it was caused by the wrong code in the "email template"! πŸ™„ .. write to DB has never had problems! 8)
    Now everything works fine! Thanks Max and Bob for the tips! πŸ˜€ πŸ˜€ πŸ˜€
    And now I'll try to study something more difficult!! :wink:
    Thanks d_folken
    This topic is locked and no more replies can be posted.