Solved

multiple conditions in 1 with '&&' ?

Posted on 2008-06-19
3
1,351 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

757 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

23 Experts available now in Live!

Get 1:1 Help Now