### [wpforms_process_validate_phone](https://wpforms.com/developers/wpforms_process_validate_phone/)

**Published:** June 26, 2020
**Author:** Editorial Team

**Excerpt:** The wpforms_process_validate_phone action fires validation on the Phone form field when the form is submitted.

**Content:**

## Description

The `wpforms_process_validate_phone` action fires validation on the **Phone** form field when the form is submitted.

## Parameters

$field\_id*(int)* Field ID.$field\_submit*(array)* Original raw/unsanitized field value submitted for the field.$form\_data*(array)* Processed form settings/data, prepared to be used later.## Source

`wpforms/includes/class-process.php`

## More Information

The action is applied to an array for **Phone** form field. This function can be used for all form fields `do_action( "wpforms_process_validate_{$field_type}", $field_id, $field_submit, $form_data )`.

It’s important to note that field values are not sanitized until later on in the processing, at `wpforms_process_format_{$field_type}`.the

## Examples

In this example shown below, the function will check the **Phone** form field for toll-free phone numbers.

```

/*
 * Check the phone field for toll-free numbers.
 *
 * @link https://wpforms.com/developers/wpforms_process_validate_phone/
 *
 * @param int     $field_id        Field ID.
 * @param array   $field_submit    Unsanitized field value submitted for the field.
 * @param array   $form_data       Form data and settings.
*/

function my_wpforms_process_validate_phone( $field_id, $field_submit, $form_data ) {

   $prefixes = [ '8', '+8' ];

   $regexp = implode( '|', $prefixes );

   if ( preg_match( '/^[' . $regexp . ']/', (string) $field_submit ) ) {
      wpforms()->process->errors[ $form_data[ 'id' ] ][ $field_id ] = esc_html__('The number should not start with "', 'wpforms') . implode( '", "', $prefixes ) . '"';
   }
}

add_action( 'wpforms_process_validate_phone', 'my_wpforms_process_validate_phone', 10, 3 );

```

## Reference Articles

- [How to Provide Additional Phone Field Validation](https://wpforms.com/developers/how-to-provide-additional-phone-field-validation/ "How to Provide Additional Phone Field Validation")
- [How to Deny Specific Phone Numbers From Submitting](https://wpforms.com/developers/how-to-deny-specific-phone-numbers-from-submitting/ "How to Deny Specific Phone Numbers From Submitting")

**Categories:** Actions Hooks

---

