Search

My form is not causing validation of the captcha. I am using Symphony which I don't really understand that well, so hopeful that this post can answer my question.

I want to ensure that the form forces validation of the captcha. Is there a way to ensure the action of the form causes validation of the reCAPTCHA? Here is the code...

<xsl:choose>

 <!-- if errors -->
 <xsl:when test="//events/contact-form/@result='error'">
 <h2>Enquiry form</h2>
 <p>* The following fields have been missed or incorrectly completed.</p>
 <form method="post" class="custom" action="" enctype="multipart/form-data">
  <input name="MAX_FILE_SIZE" type="hidden" value="5242880" />
  <!-- name field -->
  <xsl:choose>
   <xsl:when test="//events/contact-form/name/@type">
   <input class="error" name="fields[name]" type="text" placeholder="Name" />
   </xsl:when>
   <xsl:otherwise>
   <input name="fields[name]" type="text" placeholder="Name" />
   </xsl:otherwise>
  </xsl:choose>
  <!-- email field -->
  <xsl:choose>
   <xsl:when test="//events/contact-form/email/@type">
   <input class="error" name="fields[email]" type="text" placeholder="Email address" />
   </xsl:when>
   <xsl:otherwise>
   <input name="fields[email]" type="text" placeholder="Email address" />
   </xsl:otherwise>
  </xsl:choose>
  <!-- tel field -->
  <input name="fields[telephone]" type="text" placeholder="Phone number" />
  <!-- message field -->
  <xsl:choose>
   <xsl:when test="//events/contact-form/message/@type">
   <textarea class="form error" name="fields[message]" rows="15" cols="50" placeholder="Message"></textarea>
   </xsl:when>
   <xsl:otherwise>
   <textarea class="form" name="fields[message]" rows="15" cols="50" placeholder="Message"></textarea>
   </xsl:otherwise>
  </xsl:choose>
  &lt;script type="text/javascript">
 var RecaptchaOptions = {
 theme : 'clean'
 };
 &lt;/script>
   &lt;script type="text/javascript" src="http://www.google.com/recaptcha/api/challenge?k=6LckZPsSAAAAAPwnI-zEc8m5MytXq4DY6G4aCbgP">&lt;/script>
 <noscript>
   <iframe src="http://www.google.com/recaptcha/api/noscript?k=6LckZPsSAAAAAPwnI-zEc8m5MytXq4DY6G4aCbgP" height="300" width="500" frameborder="0"></iframe>
   <textarea name="recaptcha_challenge_field" rows="4" cols="60"></textarea>
   <input type="hidden" name="recaptcha_response_field" value="manual_challenge"></input>
 </noscript>
  <!-- opt out marketing? -->
  <h2 class="fieldset">Keep in the loop</h2>
  <input class="inline" name="fields[marketing-opt-out]" type="checkbox" />
  <label class="wide">We would like to send you news and details of offers from time to time. Please tick here if you do not want to receive correspondence from us.</label><br/>
  <!-- submit -->
  <input type="hidden" name="redirect" value="{$root}/thank-you" />
  <input name="action[contact-form]" class="button big red" type="submit" value="Send Message" />
 </form>
 </xsl:when>

 <xsl:otherwise>
 <h2>Enquiry form</h2>
 <form method="post" class="custom" action="" enctype="multipart/form-data">
  <input name="MAX_FILE_SIZE" type="hidden" value="5242880" />
  <input name="fields[name]" type="text" placeholder="Name" />
  <input name="fields[email]" type="text" placeholder="Email address" />
  <input name="fields[telephone]" type="text" placeholder="Phone number" />
  <textarea name="fields[message]" rows="15" cols="50" placeholder="Message"></textarea>
   &lt;script type="text/javascript">
 var RecaptchaOptions = {
 theme : 'clean'
 };
 &lt;/script>
   &lt;script type="text/javascript" src="http://www.google.com/recaptcha/api/challenge?k=6LckZPsSAAAAAPwnI-zEc8m5MytXq4DY6G4aCbgP">&lt;/script>
 <noscript>
   <iframe src="http://www.google.com/recaptcha/api/noscript?k=6LckZPsSAAAAAPwnI-zEc8m5MytXq4DY6G4aCbgP" height="300" width="500" frameborder="0"></iframe>
   <textarea name="recaptcha_challenge_field" rows="4" cols="60"></textarea>
   <input type="hidden" name="recaptcha_response_field" value="manual_challenge"></input>
 </noscript>


  <!-- opt out marketing? -->
  <h2 class="fieldset">Keep in the loop</h2>
  <input class="inline" name="fields[marketing-opt-out]" type="checkbox" />
  <label class="wide">We would like to send you news and details of offers from time to time. Please tick here if you do not want to receive correspondence from us.</label><br/>

  <input type="hidden" name="redirect" value="{$root}/thank-you" />

  <input name="action[contact-form]" class="button big red" type="submit" value="Send Message" />
 </form>
 </xsl:otherwise>

 </xsl:choose>

Do you verify the response as described here?

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details