This text input filter will validate single line input text. It is available just before submitting the form. You can do your custom validation and show error message. If $error is empty then it’s valid. Otherwise you can return the $errorMessage message as string
apply_filters('fluentform_validate_input_item_input_text', $errorMessage, $field, $formData, $fields, $form );
The following would apply to all forms:
add_filter('fluentform_validate_input_item_input_text', function ($errorMessage, $field, $formData, $fields, $form) { $fieldName = $field['name']; if (empty($formData[$fieldName])) { return $errorMessage; } $value = $formData[$fieldName]; // This is the user input value /* * You can validate this value and return $errorMessage */ return [$errorMessage]; }, 10, 5);
The following would apply to a specific form id 12:
add_filter('fluentform_validate_input_item_input_text', function ($errorMessage, $field, $formData, $fields, $form) { /* * Validate only for form id 12 */ $targetFormId = 12; if ($form->id != $targetFormId) { return $errorMessage; } $fieldName = $field['name']; if (empty($formData[$fieldName])) { return $errorMessage; } $value = $formData[$fieldName]; // This is the user input value /* * You can validate this value and return $errorMessage */ return [$errorMessage]; }, 10, 5);
Email confirmation field using email validation filter, check here.
This code should be placed in the functions.php file of your active theme.
/* * Common Filter hook names * text/Mask: fluentform_validate_input_item_input_text * email: fluentform_validate_input_item_input_email * textarea: fluentform_validate_input_item_textarea * numeric: fluentform_validate_input_item_input_number * numeric: fluentform_validate_input_item_input_number * Range Slider: fluentform_validate_input_item_rangeslider * Range Slider: fluentform_validate_input_item_rangeslider * Address: fluentform_validate_input_item_address * Address: fluentform_validate_input_item_address * Country Select: fluentform_validate_input_item_select_country * Country Select: fluentform_validate_input_item_select_country * Select: fluentform_validate_input_item_select * Radio: fluentform_validate_input_item_input_radio * Checkbox: fluentform_validate_input_item_input_checkbox * Checkbox: fluentform_validate_input_item_input_checkbox * Website URL: fluentform_validate_input_item_input_input_url * Website URL: fluentform_validate_input_item_input_input_url * Date: fluentform_validate_input_item_input_input_date * Image Upload: fluentform_validate_input_item_input_image * File Upload: fluentform_validate_input_item_input_file * Phone Filed: fluentform_validate_input_item_phone * Phone Filed: fluentform_validate_input_item_phone * Color Picker: fluentform_validate_input_item_color_picker * Net Promoter Score: fluentform_validate_input_item_net_promoter_score * Password: fluentform_validate_input_item_input_password * Ratings: fluentform_validate_input_item_ratings * Ratings: fluentform_validate_input_item_ratings */
Powered by BetterDocs