0

I noticed that another site had validation added onto Radio Buttons, and was just wondering how to add that myself?

Example: If the user selects Yes then the Validation should display. But if the user selects No then the user should be able to go the next step of the form.

This is the link I found the working example, under the Health step just select Yes: https://wmda.info/donor/become-a-donor/#gf_22

This is what I have tried so far but I am now receiving a validation for both Yes and No, which is incorrect:

add_filter( 'gform_field_validation_4_5', 'custom_validation');
 function custom_validation($value){
    if($result['$value'] = No){
    $result['$value'] = Yes;
    $result['message'] = 'Unfortunately you cannot become a blood stem cell donor.';
  }
  return $result;
 }

Kind regards,

Dale

Dale
  • 31
  • 1
  • 2
  • 8
  • 1
    `$result['$value'] = No` - that is an _assignment_, not a comparison. And likely you have no constant named `No` defined either, so that should be `'No'` instead. – misorude Feb 19 '20 at 14:00
  • 1
    And you probably also want `$result[$value]`, not `$result['$value']`. In short: You should probably go learn some basics first, because you knowledge seems to be very lacking … – misorude Feb 19 '20 at 14:01
  • I'm trying to validate radio buttons via Gravity Forms and can't find anything about it. https://docs.gravityforms.com/gform_field_validation/ – Dale Feb 19 '20 at 15:25
  • Hey Dale, I would show your validation message via an HTML field configured with conditional logic to display if the user selects "Yes". No code required. You can hide the Next button with the same logic. – Dave from Gravity Wiz Feb 20 '20 at 21:54

0 Answers0