Jump to content

If Statement For Form Validation Help Needed


jay7981

Recommended Posts

Hey guys,

I need help with an if statement, if a user chooses Yes from a radio button (Change) I need the next text field (MemberID) validated if the answer is No I want the validation skipped here is the code that I have so far:

if (empty($Change)) {
$msg_error['Change'] = "Are you changing chapters?";
}
 if ($Change == 'Yes'){
 if (empty($MemberID)) {
$msg_error['MemberID'] = "What is your previous Member ID?";
}}
 else{
 }

if (empty($fname)) {
$msg_error['fname'] = "Please enter your firstname";
}

Hey guys,

I need help with an if statement, if a user chooses Yes from a radio button (Change) I need the next text field (MemberID) validated if the answer is No I want the validation skipped here is the code that I have so far:

if (empty($Change)) {
$msg_error['Change'] = "Are you changing chapters?";
}
 if ($Change == 'Yes'){
 if (empty($MemberID)) {
$msg_error['MemberID'] = "What is your previous Member ID?";
}}
 else{
 }

if (empty($fname)) {
$msg_error['fname'] = "Please enter your firstname";
}

 

Try this:

 

if (empty($Change)) {
 $msg_error['Change'] = "Are you changing chapters?";
}
if ($Change == 'Yes' and (empty($MemberID))){
 $msg_error['MemberID'] = "What is your previous Member ID?";
}
if (empty($fname)) {
$msg_error['fname'] = "Please enter your firstname";
}

 

This assumes the only requirement is that memberid have some value...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.