---
title: Create Unique Fields in Fluent Forms
description: "Turn phone number, email, or any other simple text input into a unique field. Use the input key instead of {input_key} for your input type. See the list of input keys in this [link](https://fluentforms.com/docs/fluentform_validate_input_item_input_text/). Also, make sure the name attribute…"
url: "https://fluentforms.com/docs/create-unique-fields-in-fluent-forms/"
updated: "2023-07-25"
category: Developer Docs
tags:
  - Filter Hook
  - Tutorial
---

# Create Unique Fields in Fluent Forms

Turn phone number, email, or any other simple text input into a unique field. Use the input key instead of {input_key} for your input type. See the list of input keys in this [link](https://fluentforms.com/docs/fluentform_validate_input_item_input_text/). Also, make sure the name attribute & form ID matches correctly.

For example for the phone field use this hook: *fluentform/validate_input_item_phone*

```php
add_filter('fluentform/validate_input_item_{input_key}', function ($errorMessage, $field, $formData, $fields, $form) {

	$fieldName       = 'phone';
	$target_form_id  = 13;

	if($target_form_id !=  $form->id){ return $errorMessage; }

	if ($inputValue = FluentFormFrameworkHelpersArrayHelper::get($formData, $fieldName)) {
		$exist = wpFluent()->table('fluentform_entry_details')
			->where('form_id', $form->id)
			->where('field_name', $fieldName)
			->where('field_value', $inputValue)
			->first();

		if ($exist) {
			 $errorMessage = "Error ! This field needs to be unique.";
			 return [$errorMessage];
		}
	}

    return $errorMessage;

}, 10, 5);
```

Use this code in the theme function.php file or any PHP code snippet plugin.

Feel free to share any insights or if you have a topic in mind you would like to see documentation and example code about it. For more discussion,[https://www.facebook.com/groups/fluentforms/](https://www.facebook.com/groups/fluentforms/)join our Facebook group [Fluent Forms Community](https://www.facebook.com/groups/fluentforms/).
