We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 44095
    • 10 Posts
    Hello,

    I have a form that I have added recaptcha to below and when I submit the form with the incorrect recaptcha, it doesn't cache the inputs already entered. Any suggestions?

    Thanks!

    [[!FormIt?
       &hooks=`recaptcha,FormSave,email,emailUser,SalesForceContact,hook.RampartFormIt`
       &validate=`name:required,email:email:required,phone:required`
       &emailTpl=`contact-report`
       &emailTo=`[[++form_emails]]`
       &emailSubject=`[[++site_name]] - Contact Us Form Submission`
       &fsFormTopic=`Contact`
       &submitVar=`contactVar`
       &redirectTo=`14`
       &recaptchaJs=`{"lang":"[[++cultureKey]]", "theme":"custom", "custom_theme_widget":"recaptcha_widget"}`
    ]]
    
    <form id="contact" action="[[~[[*id]]]]" method="post" enctype="multipart/form-data">
    <input type="hidden" name="nospam:blank" value="" />
    
    <fieldset>
                [[!+fi.error.rampart]]
    [[!+fi.validation_error_message]]
      <label for="name">Your Name <span class="req">*</span></label>
      <span class="error">[[!+fi.error.name]]</span>
    	<input id="name" type="text" placeholder="Full Name *" name="name" value="Full Name *"  class="required"/>
      
      <label for="email">Your Email <span class="req">*</span></label>
    <span class="error">[[!+fi.error.email]]</span>
    	<input id="email" type="email" placeholder="Email *" name="email" value="Email *" class="required" />
      
      <label for="phone">Your Phone <span class="req">*</span></label>
    <span class="error">[[!+fi.error.phone]]</span>
        <input id="phone" type="tel" placeholder="Phone *" name="phone" value="Phone *" class="required"/>
        
      <label for="comments">Comments <span class="req">*</span></label>
    	<textarea id="comments" name="comments" rows="5" cols="19" placeholder="Comments *">Comments *</textarea>
    </fieldset>
         <input type="hidden" value="contactVar" id="contactVar" name="contactVar" class="contactVar" />
         <!-- DIV ID="recaptcha_widget" as custom_theme_widget -->
    <div id="recaptcha_widget" style="display:none">
       <!-- DIV ID="recaptcha_image" to show captcha image -->
       <div id="recaptcha_image"></div>
       <!-- ADD TEXTFIELD: "recaptcha_response_field" -->
       <input type="text" id="recaptcha_response_field" name="recaptcha_response_field" placeholder="Type the two words" />
       <!-- FormIt RESPONSE ERROR -->
       <span class="error">[[!+fi.error.recaptcha]]</span>
       <!-- Add a:link to reload captcha -->
       <div><a href="javascript:Recaptcha.reload()">Get another CAPTCHA</a></div>
       <div class="recaptcha_only_if_image"><a href="javascript:Recaptcha.switch_type('audio')">Get an audio CAPTCHA</a></div>
       <div class="recaptcha_only_if_audio"><a href="javascript:Recaptcha.switch_type('image')">Get an image CAPTCHA</a></div>
    [[!+formit.recaptcha_html]]
    
    </div>
    <form>
    <!-- FormIt recaptcha_html placeHolder -->
    	<input type="submit" class="submit" value="submit" />
    </form>	
      • 9207 ☆ A M B ☆
      • 2,475 Posts
      You need to print the values back into your fields... you can't just hard-code the value="xxxx" bit. Consider this:

      <input id="name" type="text" placeholder="Full Name *" name="name" value="[[!+fi.name]]" placeholder="Full Name *"  class="required"/>
        • 44095
        • 10 Posts
        Quote from: Everettg_99 at Aug 12, 2013, 01:49 PM
        You need to print the values back into your fields... you can't just hard-code the value="xxxx" bit. Consider this:

        <input id="name" placeholder="Full Name *" name="name" value="[[!+fi.name]]" class="required" type="text">

        That worked thanks @Everett!
          • 18913
          • 654 Posts
          Apologies for resurrecting an old thread. But could someone point me to a description of how values that were stored in an array could be reloaded? The forms values are stored in an array that is then processed. But on error those array values are not being restored.
          tia and apologies for spelling. I'm on so called smart phone.

          EDIT: This has been resolved. The source of the problem was an incorrect implementation of "FormItIsChecked". Thanks and apologies for the bandwidth waste.
          [ed. note: mconsidine last edited this post 11 years, 8 months ago.]