PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Grabbing value of a checkbox during validation?

  1. Hi there, I'm attempting to use gform_validation on a pretty convoluted form (by design). It all seems to be going well except for one part.

    The general logic of what I'm attempting to validate is the amount of emails that can be supplied for a given quantity. For example, if a value of 5 is picked, the user can "opt-in" allowing only 4 emails to be added to a text area. So far my validation works for not enough emails, too many emails, and just enough emails supplied. I however cannot figure out for life of me how to grab the value of a check-box during a validation hook in order to subtract it from the quantity value.

    Here is a look at my code : http://pastie.org/3998833.

    Basically, rgpost("input_3") is the quantity set. I pass that through to something strips whitespace, explodes emails and validates them, then checks to see if the number of emails supplied matches quantity.

    What I would like to be able to do is grab "Content-Disposition: form-data; name="input_4.1" online_self", check if it is in fact set to "online_self" and if it is, subtract one from the total amount of emails.

    Whenever I try to rgpost the input, everything breaks (I get php errors). Maybe I'm using the wrong way to call the input?

    If anyone can point me in the right direction, it would be much appreciated.

    Thanks!

    As part of my validation, I need to check to see if an input is checked or not. If it is, I need to subtract 1 from a number (namely the maximum quantity).

    Posted 7 years ago on Thursday May 31, 2012 | Permalink