I'm Working on a banking application in which i have one drop-down box to select Mode of Payment and i have two text fields for Acc No and Bank Name.
I have three inputs for Mode of payment: 1.Bank Transfer,2.Cash and 3.DD/Cheque.Now I would like to display a pop up message If the user selects the Mode of payment as Bank Transfer or DD/Cheque and leaving the two text fields i.e.,Acc No and Bank Name as blank.
MY JavaScript:
if ($F('personnel_bank_detail_mode_of_payment') == 'Bank Transfer' || 'DD/Cheque')
{
if ($F('personnel_bank_detail_account_number') == '')
{
"* Please Enter Bank Account Number\n";
}
if ($F('personnel_bank_detail_bank_id') == '')
{
"* Select Bank Name\n";
}
}
The above code is working if the user selects Bank Transfer but it is not working for DD/Cheque. How Could i make my code to work for both.Any useful suggestions will be appreciated.
Thanks!
You need to repeat what you're comparing.
if ($F('personnel_bank_detail_mode_of_payment') == 'Bank Transfer' || $F('personnel_bank_detail_mode_of_payment') == 'DD/Cheque')
If you're having some trouble with this, you can make this more obvious to yourself in the future by using parentheses around every statement.
if ((something == otherthing) || (something == someotherthing))
For the behaviour you're expecting, both sides of the ||
need to be something that evaluate to a boolean, which the ==
operator returns.