Last active
August 29, 2015 13:57
-
-
Save pzi/9824893 to your computer and use it in GitHub Desktop.
Gravity Forms additions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// This file would be inside functions.php or a custom filter plugin that get's imported into functions.php | |
// Added custom validation for minimum character count of a textfield | |
// 4 refers to the form id | |
// 6 refers to the field id in that form | |
// 10 refers to priority the filter has (WP related) | |
// 4 again is an additional parameter for gform, in this case, the id of the form the target field belongs to | |
add_filter("gform_field_validation_4_6", "validate_input_length", 10, 4); | |
function validate_input_length($result, $value, $form, $field){ | |
$minimum_character_count = 4; | |
if (strlen($value) < $minimum_character_count) : | |
$result["is_valid"] = false; | |
$result["message"] = "Please enter at least ". $minimum_character_count ." letters."; | |
endif; | |
return $result; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment