aldrin151 Posted July 1, 2008 Share Posted July 1, 2008 Hello everyone...I'm having a bit of a problem with validating a group of checkboxes...for example I have $fldalgebra_checkbox $fldcalculus_checkbox $fldgeometry_checkbox $fldtrigonometry_checkbox At least one of these fields need to be checked for the form not to generate any FormErroMessage "Please check at least one of these fields". I tried if ($fldalgebra_checkbox != "1" || $fldcalculus_checkbox != "1"){ $sEditInterestsErr .= "Please check at least one of these fields.</br>"; } This doesn't work for obvious reasons...Can someone help me use a method that works? Regards Aldrin Link to comment https://forums.phpfreaks.com/topic/112817-validate-at-least-one-checkbox-selected/ Share on other sites More sharing options...
lemmin Posted July 1, 2008 Share Posted July 1, 2008 The name and value of the checkbox will not get put into the $_GET or $_POST array if it is not checked so you can just check if they are set: if (!isset($_GET['fldalgebra_checkbox']) || [...]) echo "One is not set"; Link to comment https://forums.phpfreaks.com/topic/112817-validate-at-least-one-checkbox-selected/#findComment-579469 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.