Form Tools
Opposite of same_as - 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: Opposite of same_as (/showthread.php?tid=12822)



Opposite of same_as - michatmaster7 - May 18th, 2016

Hey guys -

Not sure if this can be done with reg_exp or not, but I'd like to create a PHP validation rule that is exactly the opposite of same_as. For example, on a form, the customer is allowed to choose their 1st choice and their 2nd choice, but I don't want to let them choose the SAME choice in both fields. Each of the 1st and 2nd choices needs to be different from each other. Any thoughts?

B

I can see in the validation.php file where the same_as rule is written, and I could easily just create another case in that file, but I want to make sure it never gets overwritten (you know, like a WP child theme's functions.php).

/global/code/validation.php:367-370
PHP Code:
case "same_as":
        if (
$fields[$field_name] != $fields[$field_name2])
          
$errors[] = $error_message;
        break;