• Resolved diegpl

    (@diegpl)


    Hi, I am trying to check if a specific field contains the number “300”. I tried this code, but it did not work. Does some one here know if I am doing something wrong?

    add_action( 'woocommerce_after_checkout_validation', 'misha_validate_fname_lname', 10, 2);
     
    function misha_validate_fname_lname( $fields, $errors ){
     
        if ( strpos( $fields[ 'billing_n_matricula' ], 300) === false   ){
            $errors->add( 'validation', 'Seu número de matrícula parece estar errado, favor digitar o correto.' );
        }
    }

    Tks! ??

    • This topic was modified 5 years, 3 months ago by diegpl.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter diegpl

    (@diegpl)

    It seems the code runs, since I see the validation warning, but it never gets true, to go ahead. Tks!

    Plugin Support Hannah S.L.

    (@fernashes)

    Automattic Happiness Engineer

    I’m glad to hear you solved this – thanks for letting us know!

    Thread Starter diegpl

    (@diegpl)

    I have actually told it never gets true in the code logic to not get the warning, I did not solve the problem…

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Custom input validation’ is closed to new replies.