Solved

multiple conditions in 1 with '&&' ?

Posted on 2008-06-19
3
1,352 Views
Last Modified: 2013-11-19
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
Comment
Question by:behets
3 Comments
 
LVL 7

Expert Comment

by:Zippit
ID: 21821107

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
 
LVL 8

Expert Comment

by:Bird Dog
ID: 21821126
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
 
LVL 14

Accepted Solution

by:
ali_kayahan earned 250 total points
ID: 21821143
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now