Nov 2nd, 2017, 6:52 PM
(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