Home › Forums › Quform WordPress › errors on page trigger custom validation as invalid
I have a custom validation for a field done like this:
function my_validate_greater_than_18($valid, $value, $element){
if(!is_numeric($value) || strlen($value) != 13 || !checkdate(substr($value,3,2),substr($value,5,2),substr($value,1,2))) $valid = false; $element->addError('CNP INVALID'); $key = '279146358279'; for($i=0;$i < 12;$i++) $sum += $value[$i]*$key[$i]; $rest = ($sum % 11 == 10)? 1 : $sum % 11; // $element->addError('CNP ##### VALID #####'); return(($rest == $value[12]) ? true : false);
} add_filter('iphorm_element_valid_iphorm_1_1', 'my_validate_greater_than_18', 10, 3);
the code works fine, BUT if I have other fields on page that they are required e.g. name and are not completed on SUBMIT I get the error message from the “iphorm_1_1” field EVEN if its content is VALID
please let me know what i do wrong here.
thanks!
You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
Yes, silly me! Thanks!