FORMfields, the premiere web framework
Login
Support Home | Knowledge Base | Documentation | Forums | Contact Us
Info
FORMfields & FORMgen :: Validation

Verifying an Email Address (Retyping an Email)

(2145 views. Last Updated: 2008-03-29 1:15 PM)

You can verify that an email address has been entered correctly by using a second EmailAddrField and using the following validation checking:

If your form has two EmailAddrFields named "email1" and "email2", then you can insert the following code to verify that the email addresses are the same:
...
function onClick(&$ffForm)
{
    //echo "CONFIRM<hr/>";
    if ($ffForm->getValue("email1") !== $ffForm->getValue("email2")) {
        $ffForm->setError("email2", "Email addresses must match!");
    }
    if ($ffForm->checkValues()) {
..

Also, if you don't want the second email address to appear in the database or in the email, you can use the following:
$ffForm->addField(new EmailAddrField("email2", "Re-Type Email", FORM_FIELD_REQUIRED));
$ffForm->formFields["email2"]->setData(false);
Info
Support | Earn Money
Copyright © 2005-2019 Brain Book Software LLC.
Built with FORMfields, the premiere web framework.