Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1360
  • Last Modified:

multiple conditions in 1 with '&&' ?

Hi,

can somebody say me how do i make multiple conditions at once in javascript?
The code that i include shows you how i do it now, but i would like to know how to make it one 'if(...)....{}'
not 'if(...){ if(...){...} }'
if (!document.form1.parents.checked == 1)
   {    if (document.form1.gebjaar.value > "1990") {
      		alert("You have to accept the parents approval checkbox to go on");
      		return false;}
   }

Open in new window

0
behets
Asked:
behets
1 Solution
 
ZippitCommented:

if((!document.form1.parents.checked == 1) && (document.form1.gebjaar.value > "1990")) {
    alert("You have to accept the parents approval checkbox to go on");
    return false;
}

Open in new window

0
 
Bird DogCommented:
I have not used java in quite a while but I remember using the and (&&) operator for the same thing you are trying to do or use the or (||) operator
0
 
Ali KayahanFull Stack DeveloperCommented:
Or you may use shortened way like the code below basicly its logic is
 condition ? run if condition is true : run if condition is false
!document.form1.parents.checked == 1 ? alert("You have to accept the parents approval checkbox to go on") : document.form1.gebjaar.value > "1990" ? alert("You have to accept the parents approval checkbox to go on") : return false ;

Open in new window

0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now