errors on page trigger custom validation as invalid

Home Forums Quform WordPress errors on page trigger custom validation as invalid

This topic is: resolved
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #15474
    pajura
    Participant

    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-&gt;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!

    • This topic was modified 8 years, 10 months ago by Ally.
    #15476
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #15492
    pajura
    Participant

    Yes, silly me!
    Thanks!

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Be inspired. © 2024 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy