Support » Plugin: Brilliant Web-to-Lead for Salesforce » Validating Phone field

  • Resolved semikola

    (@semikola)


    Hi there,

    in my telephone field the user has to insert the phone number with the international prefix.

    Is it possible to validate the field before it get sent to Saleforce, and be sure that the prefix is there? So that I can also show an error message if the user didn’t insert the number correctly?

    Thanks a lot,

    Simone

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi there,

    I found the solution in the documentation :’)

    Here what worked for me:

    // Check if phone number has internazional prefix
    function check_international_prefix( $error, $name, $val, $field ){
        
        if ( $name == 'phone' ){
    
            $phone = $val;
    
            if ( strpos( $phone, '+39' ) === 0 || strpos( $phone, '0039' ) === 0 ) {
                $error['valid'] = true;
            } else {
                $error['valid'] = false;
                $error['message'] = 'Inserisci anche il prefisso internazionale +39.';
            }
    
        }
    
        return $error;
    }
    add_filter( 'sfwp2l_validate_field', 'check_international_prefix', 10, 4 );

    Thanks a lot and sorry,

    Simone

    • This reply was modified 1 year, 3 months ago by semikola.
    • This reply was modified 1 year, 3 months ago by semikola.
    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    @semikola Why did you report your topic?

    Plugin Author Nick Ciske

    (@nickciske)

    @semikola Glad you figured it out!

    @jdembowski it was a mistake!

    Simone

    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    That’s a relief, I thought I was missing something obvious. Mistakes are fine. 😉

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Validating Phone field’ is closed to new replies.