Form Tools
Email Validation or Confirm Email - Printable Version

+- Form Tools (https://forums.formtools.org)
+-- Forum: Modules / Other (https://forums.formtools.org/forumdisplay.php?fid=8)
+--- Forum: Form Validation: JS + PHP (https://forums.formtools.org/forumdisplay.php?fid=18)
+--- Thread: Email Validation or Confirm Email (/showthread.php?tid=5221)



Email Validation or Confirm Email - Darkfx - Jun 26th, 2015

Hi,

Is there anyone to make your email field to validate or confirm to the second email field like the attached image.

If anyone can help would be appreciate! Smile


RE: Email Validation or Confirm Email - jpmd - Apr 16th, 2016

Yes, I would like that too!


RE: Email Validation or Confirm Email - ocbroadband - Nov 2nd, 2017

(Apr 16th, 2016, 7:27 AM)jpmd Wrote: Yes, I would like that too!

Validation Rules will do that.  I'm doing that exact thing on my form.  It is external however, so I'm not sure what your using.

PHP Code:
<?php
require_once("/path/to/formtool/global/api/api.php");
$fields ft_api_init_form_page(2);

// validation time!
$errors = array();
if (isset(
$_POST['sbmt']))
 
    {
 
   $rules = array();
 
    $rules[] = "valid_email,emailaddress,Please enter a valid email address.";
 
    $rules[] = "same_as,emailaddress,emailaddress2,Please insure your confirmation email is the same.";
 
    $errors validate_fields($_POST$rules);
 
   
// no errors - great! Now we process the page. The ft_api_process_form does
// the job of both updating the database and redirecting to the next page
 
   if (empty($errors))
 
        {
 
       $params = array(
 
           "submit_button" => "sbmt",
 
            "next_page" => "https://www.xxx.com/wp/thank-you/",
 
            "form_data" => $_POST,
 
            "finalize" => true
            
);
 
        ft_api_process_form($params);
 
        
// it failed validation. Update $fields with the latest contents of the form data
 
   else
         
{
 
       $fields array_merge($_SESSION["form_tools_form"], $_POST);
 
        
 
   
?>

Then in my form, I have this for the 2 email fields to compare.

PHP Code:
     <tr>
 
       <td align="right" valign="top" width="35%">Email Address<br>
 
       </td>
 
       <td valign="top" width="618"><input maxlength="40" size="40" type="text" name="emailaddress" value="<?=@$fields["emailaddress"]?>" /> *-Required</td>
 
     </tr>
     
  <tr>
 
       <td align="right" valign="top" width="35%">Confirm Email Address<br>
 
       </td>
 
       <td valign="top" width="618"><input maxlength="40" size="40" type="text" name="emailaddress2" value="<?=@$fields["emailaddress2"]?>" /> *-Required</td>
 
     </tr

Hope this helps.

Lyle