grk101 Posted May 11, 2009 Share Posted May 11, 2009 thought i would post in here about this.. I have this html <span style="font-weight:bold">Are you available to coach?* </span> <label for="areyou"> <input type="radio" name="avcoach" id="avcoach" value="Yes"></label> Yes <label for="areyou"> <input type="radio" name="avcoach" id="avcoach" value="No"></label> No </td> <td> </td> </tr> <tr> <td colspan="5"><span style="font-weight:bold">If yes,</span> <label for="ifyes"> <input type="radio" name="coachrep" id="coachrep" value="Head Coach/Team Rep"></label> Head Coach/Team Rep <label for="ifyes"> <input type="radio" name="coachrep" id="coachrep" value="Assistant Coach/Team Rep"></label> Assistant Coach/Team Rep</td> Currently in my validation in php it makes both fields mandatory. like this if (strlen($avcoach) == 0 ) { die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please tell us if you can Coach/Rep</font></p>"); } if (strlen($coachrep) == 0 ) { die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please tell us if you want to be an Assistance Coach/Rep</font></p>"); } Realistically i wanted to do the following: Do you want to Coach/Rep , Yes then fill out the type of coach/Rep , but if not move on u know? So only make the following mandatory if they select YES from above. <span style="font-weight:bold">If yes,</span> <label for="ifyes"> <input type="radio" name="coachrep" id="coachrep" value="Head Coach/Team Rep"></label> Head Coach/Team Rep <label for="ifyes"> <input type="radio" name="coachrep" id="coachrep" value="Assistant Coach/Team Rep"></label> Assistant Coach/Team Rep Link to comment https://forums.phpfreaks.com/topic/157721-php-validation-on-html-form-two-choices/ Share on other sites More sharing options...
JD* Posted May 11, 2009 Share Posted May 11, 2009 On your validation page, have this: if($_POST['avcoach'] == "yes" && empty($_POST['coachrep'])) { die("Your error message here"); } Link to comment https://forums.phpfreaks.com/topic/157721-php-validation-on-html-form-two-choices/#findComment-831830 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.