Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // http://www.gravityhelp.com/forums/topic/field-validation
- // http://www.gravityhelp.com/forums/topic/match-fields
- // update the 1 here to your form ID
- add_filter('gform_validation_1', 'matching_field_validation', 10, 2);
- function matching_field_validation($validation_result){
- $form = $validation_result['form'];
- // this compares field 2 to field 3, update these values to match your form
- if (rgpost('input_2') !== rgpost('input_3')) {
- // this is the validation error for input_1
- $form['fields'][0]['failed_validation'] = true;
- $form['fields'][0]['validation_message'] = 'This field must match the next one.';
- // this is the validation error for input_2
- $form['fields'][1]['failed_validation'] = true;
- $form['fields'][1]['validation_message'] = 'Please verify your entries.';
- $validation_result['is_valid'] = false;
- }
- // update the form in the validation result with the form object you modified
- $validation_result['form'] = $form;
- return $validation_result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement