• Hi,

    I need your advice on how to set the validation for phone number using the starting number. For example, only phone number start with 6 or 8 or 9 then will go allow.

    Please advise, many thanks.

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

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Takayuki Miyoshi

    (@takayukister)

    Thread Starter samuelng527

    (@samuelng527)

    Hi @takayukister,

    The Custom validation you have provided is for email, how can I modify this code for the phone validation?

    Please help, many thanks.

    Thread Starter samuelng527

    (@samuelng527)

    Hi @takayukister,

    I have inserted the below code but still not working. Please advise where goes wrong.

    add_filter( ‘wpcf7_validate_tel*’, ‘custom_tel_confirmation_validation_filter’, 20, 2 );

    function custom_tel_confirmation_validation_filter( $result, $tag ) {
    if ( ‘ReenterContactnumber’ == $tag->name ) {
    $Contactnumber= isset( $_POST[‘contact-number-required’] ) ? trim( $_POST[‘contact-number-required’] ) : ”;
    $ReenterContactnumber= isset( $_POST[‘re-enter-contact-number-required’] ) ? trim( $_POST[‘re-enter-contact-number-required] ) : ”;

    if ( $ Contactnumber!= $ReenterContactnumber) {
      $result->invalidate( $tag, "Are you sure this is the correct number?" );
    }

    }

    return $result;
    }

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Validate Phone Number with Starting Number’ is closed to new replies.