<?php
add_filter( 'gform_validation_1', 'v_validate');
function v_validate( $validation_result ) {
$form = $validation_result['form'];
//require match from field 1&2. If they dont, display/require field 11.
if ( $validation_result['is_valid'] && (rgpost( 'input_2' ) != rgpost( 'input_1' )) ) {
//only run this if input_11 is blank. if it has a value, then it must be Yes or throw an error
if(rgpost( 'input_11' ) == '') {
$validation_result['is_valid'] = false;
foreach($form['fields'] as &$field) {
if($field->id == '2') {
$field->failed_validation = true;
$field->validation_message = 'Your validation message here.';
//break;
}
if($field->id == '11') {
$field->visibility = 'visible';
$field->isRequired = 1;
//break;
}
}
}
//Assign modified $form object back to the validation result
$validation_result['form'] = $form;
return $validation_result;
}