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

    Made this today to validate two email input fields in a formit form. There is already a validator for 2 passwords, but there isn't for anything else so I made this little snippet and posted it here for those that need something similar.

    How to set it up in formit:
    [[!FormIt? 
    &hooks=`email`
    &customValidators=`is_confirm_email`
    &validate=`
      email:email:required,
      confirm_email:is_confirm_email=`email``]]
    


    Make a snippet with the name is_confirm_email:
    <?php
      $confirm_email = ($_POST[$param]);
      $success = $value == $confirm_email;
      if (!$success) {
        $validator->addError($key,'E-mail is not correct.');
      }
      return $success;
    


    This goes in the form
    <label for="email">E-mail*: [[!+fi.error.email]]</label>
    <input type="text" name="email" id="email" value="[[!+fi.email]]" />     
     
    <label for="confirm_email">Confirm E-mail: [[!+fi.error.confirm_email]]</label>
    <input type="text" name="confirm_email" id="confirm_email" value="[[!+fi.confirm_email]]" /> 


    Open for any suggestions or improvements. [ed. note: sjeijk last edited this post 14 years, 6 months ago.]
      • 36551
      • 416 Posts
      Hi Sjeijk

      Just what I need.

      So do we create a new snippet and call it what? Or does this go inside an existing snippet? If so where?

      Thanks.
        • 27437
        • 49 Posts
        Updated the first post. [ed. note: sjeijk last edited this post 14 years, 6 months ago.]
          • 36551
          • 416 Posts
          Sjeijk

          Thanks for that. I got it working.

          I found that I had to put any other field validation before the email confirm in order for it to work properly.

          [[!FormIt? &hooks=`spam,email,redirect` &emailTpl=`ApptChunk` &emailTo=`[email protected]` &redirectTo=`13` &emailSubject='Appointment Request' &emailUseFieldForSubject=`1` &customValidators=`is_confirm_email` &validate=`firstname:required, lastname:required, appttype:required, prefday:required, mornaft:required, email:email:required, confirm_email:is_confirm_email=`email` `]]


          Thanks again!


            • 36924 ☆ A M B ☆
            • 298 Posts
            This is nice. Thanks