ontarget
Active Member
Hi
I am trying to validate a field to prevent people from putting their email address in it.
I tried a php validation in both the condition and PHP Code fields:
if (!filter_var($data, FILTER_VALIDATE_EMAIL)) {
return false;
}
In the PHP Code the rule is seemingly ignored and the form just submits despite there being an email address in the field value
Also tried a regex solution:
if (preg_match('/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/',$data)){
return false;
}
With this in the PHP Code the rule is also ignored and the form just submits despite there being an email address in the field value
Does there need to be a condition in order for the PHP code to run? I couldnt see this in the Wiki
for example this doesnt work - it returns the error message field irrespective of the value:
Condition:
if (!filter_var($data, FILTER_VALIDATE_EMAIL)) {
return true;
}
//An email has been found so run return false in PHP code
PHP Code:
return false;
I am trying to validate a field to prevent people from putting their email address in it.
I tried a php validation in both the condition and PHP Code fields:
if (!filter_var($data, FILTER_VALIDATE_EMAIL)) {
return false;
}
In the PHP Code the rule is seemingly ignored and the form just submits despite there being an email address in the field value
Also tried a regex solution:
if (preg_match('/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/',$data)){
return false;
}
With this in the PHP Code the rule is also ignored and the form just submits despite there being an email address in the field value
Does there need to be a condition in order for the PHP code to run? I couldnt see this in the Wiki
for example this doesnt work - it returns the error message field irrespective of the value:
Condition:
if (!filter_var($data, FILTER_VALIDATE_EMAIL)) {
return true;
}
//An email has been found so run return false in PHP code
PHP Code:
return false;