[[!FormIt? &submitVar=`answ` &hooks=`redirect` &redirectTo=`[[+page]]` &validate=` answ:contains=^[[+altcode]]:or:[[+code]]^` ]]
This question has been answered by Bruno17. See the first response.
<?php /* & customValidators=`containsOneOfThem` & validate=`message:containsOneOfThem=^Hello,Dear,Hi,Hey^` */ $params = explode(',',$param); $success = false; foreach ($params as $param){ if (strstr($value,$param)){ $success = true; } } if (!$success) { // Note how we can add an error to the field here. $validator->addError($key,'one or more words are missing'); } return $success; ?>
<?php /* & customValidators=`equalsOneOfThem` & validate=`color:equalsOneOfThem=^red,green,blue^` */ $params = explode(',',$param); $success = false; foreach ($params as $param){ if ($value==$param){ $success = true; } } if (!$success) { // Note how we can add an error to the field here. $validator->addError($key,'one or more words are missing'); } return $success; ?>
Or:
<!--?php /* & customValidators=`equalsOneOfThem` & validate=`color:equalsOneOfThem=^red,green,blue^` */ $params = explode(',',$param); $success = false; foreach ($params as $param){ if ($value==$param){ $success = true; } } if (!$success) { // Note how we can add an error to the field here. $validator--->addError($key,'one or more words are missing'); } return $success; ?>