Nested If..Else Statement?

Results 1 to 2 of 2

Thread: Nested If..Else Statement?

  1. #1
    Join Date
    Dec 1969

    Default Nested If..Else Statement?

    Ok, I am having an issue with brain freeze today. This is a simple question. I have done this before but I just can&#039;t remember how I did it or where. I know I need nested IF statements I just can&#039;t think what logic is that I need.<BR><BR>I have 4 fields: field1, field2, field3, and field4.<BR><BR>Only one set of fields can be used at a time, either 1 & 2 or 3 & 4. Both fields in each set must be used and the user should not be able to submit the form with nothing in any fields.<BR><BR>Does anyone have an example of this that i can view. <BR><BR>Thanks in advance.<BR>

  2. #2
    Join Date
    Dec 1969

    Default You've answered it ?

    &#062;&#062; "either 1 & 2 or 3 & 4"<BR><BR>in code:<BR><BR> if ((Box1!=""&&Box2!="") &#124&#124 (Box3!=""&&Box3!="")){<BR> // Form correctly entered. <BR> }<BR><BR>But Presumably you want to test for the opposite, i.e incorrectly filled in form, so we flip the logic (ahh binary logic uni days!!):<BR><BR> if ((Box1==""&#124&#124Box2=="") && (Box3==""&#124&#124Box3=="")){<BR> // Form incorrectly entered. <BR> alert("enter values in two boxes");<BR> }<BR><BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts