Welcome Guest, Not a member yet? Register   Sign In
Radio Buttons with Other (please specify)
#1

[eluser]K-Fella[/eluser]
How would I go about dealing with a form that has a group of radio buttons where one is set to 'Other' with a seperate input field provided?

How can I validate that the input field has been populated if the 'Other' radio button has been selected?
#2

[eluser]Nillian[/eluser]
Could you not just check your POST data to see if the 'Other' button was selected (using an IF statement), and then validate the Other field if the radio button has been selected? Or perhaps I misunderstand?
#3

[eluser]K-Fella[/eluser]
What I would like to do is use the validation library, but I don't know how to do it. At the moment it does a callback to check if no buttons were selected. But because the 'Other' input field is seperate from the group of radio buttons, it has it's own POST value. Therefore I don't see a way of setting up a rule that checks if one rule equal 'Other' to check another rule. Can a callback invoke another callback? If so, this would work.
#4

[eluser]Michael Wales[/eluser]
Yes - use the callbacks for it.

Code:
function __callback1() {
  return $this->__callback2();
}

function __callback2() {
  return TRUE;
}

Should work - give it a try.




Theme © iAndrew 2016 - Forum software by © MyBB