Here's the deal: I have three checkboxes. The user needs to at least select one out of the three. If they check an IMPORTED check box, then they need to fill out other text fields.
Here's what I have:
if(!isset($_POST['new'])|| !isset($_POST['recycled']) || !isset($_POST['imported'])){
$message[]="Please select new, recycled, or imported";
}
else if($_POST['imported']){
if(eregi("^(Spring|Fall|Summer)\ 20[0-9]{2}", $_POST['lastimport'])){
$d=true;
}
else{
$d=false;
$message[]="Please enter a valid last import, ex., <span class=\"error\">Fall 2005, Spring 2006 or Summer 2004</span>";
}
if(eregi("[a-z | A-Z]+", $_POST['coursecodeimported'])){
$d=true;
}else{
$d=false;
$message[]="Please enter a valid course code, ex., <span class=\"error\"> ENG </span>";
}
if(eregi("[0-9]+", $_POST['coursenumberimported'])){
$d=true;
}else{
$d=false;
$message[]="Please enter a valid course number, ex., <span class=\"error\"> 01, 02, 03 </span>";
}
if(eregi("[0-9]+", $_POST['sectionnumberimported'])){
$d=true;
}else{
$d=false;
$message[]="Please enter a valid section number, ex., <span class=\"error\"> 01, 02, 03</span>";
}
if(eregi("^[A-Z]{3}\-[0-9]{3}\-[A-Z0-9]{4}", $_POST['blackboardcourseidimported'])){
$d=true;
}
else{
$message[]="Please enter a valid black board course id, ex., <span class=\"error\">ENG-110-ENG0</span>";
}
}
else{
$message[]="If you chose IMPORTED from question 2, you must fill in the following fields: ";
}
Logic should be fairly straightforward. I first check to see if any checkboxes are empty, if so throw an error message, which is fine. If imported is checked, I need check to make sure the other text fields are filled and throw an error message indicating this. This functionality does not work. I can't figure out how to make the import check require the other field errors (if any) to show up. Checking additional buttons does not matter in this series.
Here's a visual example (code does not work)
http://midwestwebdesign.net/test.html
If anyone could spot something I would be appreciative.