By default the custom validation message that is entered under the Advanced tab of the field editor should override the default validation message. But in the case of the no duplicates option, it doesn't appear to be doing so. I will look into why and get it changed so that the custom validation message does override the default in this situation.
There is also a hook that can be used to implement custom validation. It is called the gform_validation hook.
Here is an example of it's use:
<?php
add_filter('gform_validation', 'custom_validation');
function custom_validation($validation_result){
// set the form validation to false
$validation_result["is_valid"] = false;
$form = $validation_result["form"];
// specify the first field to be invalid and provide custom validation message
$form["fields"][0]["failed_validation"] = true;
$form["fields"][0]["validation_message"] = "This field is invalid!";
// update the form in the validation result with the form object you modified
$validation_result["form"] = $form;
return $validation_result;
}
?>
Posted 13 years ago on Saturday February 19, 2011 |
Permalink