How to know if a variable is null

Discussion in 'Software' started by peace2007, Sep 29, 2007.

  1. peace2007

    peace2007

    Joined:
    Sep 25, 2007
    Messages:
    7
    Hi,

    I try to check if a variable is null via following code but I don't get an expected result:
    Code:
     var askedUser = re.responseText;
    		    askedUser = askedUser.substr(0, askedUser.indexOf('&',0));
    			if(askedUser != null  && askedUser != " ")
    			{	do something}
    the if() returns true whether askedUser == "" or askedUser = "a value"!
    Could anyone guide me please?
     
    peace2007, Sep 29, 2007
    #1
    1. Advertising

  2. peace2007

    hamedvahedi

    Joined:
    Sep 26, 2007
    Messages:
    5
    Location:
    Iran
    Change your code to this:
    if(askedUser != NULL && askedUser != "")

    Attention: NULL and ""

    www.hamedvahedi.com
     
    Last edited: Sep 30, 2007
    hamedvahedi, Sep 30, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mel

    Null Route

    Mel, Jan 11, 2004, in forum: Cisco
    Replies:
    1
    Views:
    2,276
    Hansang Bae
    Jan 11, 2004
  2. Matt

    AS5800 null routes

    Matt, Jan 28, 2004, in forum: Cisco
    Replies:
    0
    Views:
    356
  3. Martin Bilgrav

    PIX Firewall - PDM Null Rule ?

    Martin Bilgrav, Feb 20, 2004, in forum: Cisco
    Replies:
    0
    Views:
    2,688
    Martin Bilgrav
    Feb 20, 2004
  4. sqrfolkdnc

    Making V.35 F/F crossover null modem

    sqrfolkdnc, Mar 12, 2005, in forum: Cisco
    Replies:
    0
    Views:
    1,108
    sqrfolkdnc
    Mar 12, 2005
  5. Jim
    Replies:
    2
    Views:
    2,543
Loading...

Share This Page