Matt Elhotiby
Matt Elhotiby

Reputation: 44086

whats wrong with this JS

firebug is complaining its there is a syntax error

if (document.getElementById("fromAddress").value == "") || 
(document.getElementById("fromAddress").value == "Enter Address, City, Directions") {   

Upvotes: 0

Views: 109

Answers (4)

Zafer
Zafer

Reputation: 2190

Corrected form: (removed 2 parentheses)

if (document.getElementById("fromAddress").value == "" || document.getElementById("fromAddress").value == "Enter Address, City, Directions") {

Upvotes: 1

Sarfraz
Sarfraz

Reputation: 382909

You have mis-match of parenthesis, try this:

if ((document.getElementById("fromAddress").value == "") || 
(document.getElementById("fromAddress").value == "Enter Address, City, Directions")){...}

Upvotes: 1

Michael Haren
Michael Haren

Reputation: 108376

You need to wrap the entire conditional statement in parans:

if ( (blah) || (blah) )
   ^                  ^
{
  // as you were
}

Upvotes: 4

ChaosPandion
ChaosPandion

Reputation: 78302

You are missing the parenthesis, that being said you are better off writing it like this.

var from = document.getElementById("fromAddress").value;
if (from  === "" || from  === "Enter Address, City, Directions") { 

Upvotes: 7

Related Questions