Solved

multiple conditions in 1 with '&&' ?

Posted on 2008-06-19
3
1,357 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

617 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