# Elementor Forms: Check Phone Numbers

> Rejects Elementor Pro form submissions whose phone (Tel) field contains letters or too few digits, so you get numbers you can actually call back.

- Type: PHP
- Runs: Run everywhere
- Category: [Page Builders & Themes](https://wpide.com/library/category/page-builders/)
- Tags: elementor, forms, validation, phone
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/elementor-form-phone-validation/

## Code

```php
// Allowed number of digits in a phone number.
$wpide_el_phone_min = 7;
$wpide_el_phone_max = 15;

add_action( 'elementor_pro/forms/validation/tel', function ( $field, $record, $ajax_handler ) use ( $wpide_el_phone_min, $wpide_el_phone_max ) {
    $value = isset( $field['value'] ) ? trim( (string) $field['value'] ) : '';

    if ( '' === $value ) {
        return;
    }

    $digits = strlen( preg_replace( '/\D/', '', $value ) );

    if ( preg_match( '/[^0-9+()\.\-\s]/', $value ) || $digits < $wpide_el_phone_min || $digits > $wpide_el_phone_max ) {
        $ajax_handler->add_error( $field['id'], 'Please enter a valid phone number.' );
    }
}, 10, 3 );
```

## Notes

Change the minimum and maximum digit counts for your country.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Elementor Forms: Check Phone Numbers" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
