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.]