New to this forum, but thought I would give it a try, here's the problem:
Radio button on a form, if the user does NOT select anything, I need to show
an error message. If the user selects yes on this radio button, I need to
make sure a specific field is filled in, if not, show an error message
related to the text field, but NOT the error message from the radio button.
Selecting NO, requires nothing.
Here's the code I came up with:
if(!isset($_POST['LegalResidencelessthan1yr'])){
$d=true;
if(eregi("[a-z | A-Z]+", $_POST['FormerCity'])){
$d=true;
}else{
$d=false;
$message[]="Please enter a valid former city, ex., <span
class=\"error\">Springfield</span>";
}
if(eregi("[a-z | A-Z]+", $_POST['FormerState'])){
$d=true;
}else{
$d=false;
$message[]="Please enter a valid former state, ex., <span
class=\"error\">MO</span>";
}
if(eregi("[a-z | A-Z]+", $_POST['FormerSchoolDist'])){
$d=true;
}else{
$d=false;
$message[]="Please enter a valid former school district, ex., <span
class=\"error\">Springfield R-12</span>";
}
}
else{
$d=false;
$message[]="Please select whether you have lived at your legal residence
less than one year.";
}
Legal residence is the radio button. Former City, Former State and Former
School Dist are the text fields that are required after selecting yes. To me
this looks like it should work. The text field(s) validation does work, the
radio button does not. If anyone can spot a problem let me know or needs
further info I would gladly provide it.