Advertisement
Guest User

Untitled

a guest
Sep 18th, 2012
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. <?php
  2. // http://www.gravityhelp.com/forums/topic/field-validation
  3. // http://www.gravityhelp.com/forums/topic/match-fields
  4. // update the 1 here to your form ID
  5. add_filter('gform_validation_1', 'matching_field_validation', 10, 2);
  6. function matching_field_validation($validation_result){
  7.  
  8. $form = $validation_result['form'];
  9. // this compares field 2 to field 3, update these values to match your form
  10. if (rgpost('input_2') !== rgpost('input_3')) {
  11. // this is the validation error for input_1
  12. $form['fields'][0]['failed_validation'] = true;
  13. $form['fields'][0]['validation_message'] = 'This field must match the next one.';
  14. // this is the validation error for input_2
  15. $form['fields'][1]['failed_validation'] = true;
  16. $form['fields'][1]['validation_message'] = 'Please verify your entries.';
  17. $validation_result['is_valid'] = false;
  18. }
  19.  
  20. // update the form in the validation result with the form object you modified
  21. $validation_result['form'] = $form;
  22. return $validation_result;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement