This topic is locked

validate 2 fields

2/11/2008 2:20:50 PM
PHPRunner General questions
M
mrpeeble author

Hi,
I am having some trouble with this validation code in BeforeEdit.
I have 2 comboboxes with default value of "Not Addressed" for both. What I want is to make the user fill out both comboboxes before he saves. I do not want to allow changing one but not the other from the default value before a save. With the following code, when I change both comboboxes the alert message still flashes and the save does not take place. Any help would be appreciated.
if ($values["IRPaymentAction"] = "Not Addressed" or $values["IRCaseAction"] = "Not Addressed")

{

echo '<script language=javascript>alert("You must complete both Payment Action and Case Action before saving.")</script>';

return false;

}
return true;

A
alang 2/11/2008

Try using PHP equality check which is "==" rather than the assignment operator "=". ie
if ($values["IRPaymentAction"] == "Not Addressed" or $values["IRCaseAction"] == "Not Addressed")

M
mrpeeble author 2/12/2008

Yikes !
no matter how many hours I stare at code I can never get it through my head to use the == for equals.
Thanks for the help.