Hi all we are currently using this code that will limit the title text to 100 characters, We would like to extend this defined function to the "tags id 8", "email id 11", "companies name id 17", "contact name id 18", "web address id 19", field as well. We have people using 100's of tags that rally ugly's up our results page as you can see on some of the older posts on our new site http://www.adszoom.com Check out the post page preview after the form is rendered as well. We do not want the post's info to over flow the theme so this is a must. You may have to just log in and do a test post to see what i mean. The content is protected so i can't supply the 2nd preview for you to see....
<?php
add_filter('gform_validation_2', 'title_length');
function title_length($validation_result){
$form = $validation_result["form"];
//supposing we don't want input_1 to be longer than 100 characters.
if(strlen($_POST['input_1']) > 100){
// set the form validation to false
$validation_result["is_valid"] = false;
//finding Field with ID of 1 and marking it as failed validation
foreach($form["fields"] as &$field){
//NOTE: replace 1 with the field you would like to validate
if($field["id"] == "1"){
$field["failed_validation"] = true;
$field["validation_message"] = "Your title is too long 100 characters Google max";
break;
}
}
}
//Assign modified $form object back to the validation result
$validation_result["form"] = $form;
return $validation_result;
}
?>