if(fullname == "full name") - This brings up an error?

Discussion in 'JavaScript' started by fri3ndly, Dec 30, 2008.

  1. #1
    Hello all

    I am a bit of a JS noob but have been writing it recently but something is puzzling me.

    I have a name field which contains 'full name' until it is clicked. I am trying to make the js form validation pick up wjether the field contains 'full name' and if so bring up an error message, however I am having a problem with anything containing a space.

    Eg. the below works:
    
    if(fullname == "") {
        inlineMsg('fullname','You must enter your full name.',2);
        return false;
      }
    
    Code (markup):
    But this doesn't:
    
    if(fullname == "full name") {
        inlineMsg('fullname','You must enter your full name.',2);
        return false;
      }
    
    Code (markup):
    Is there any special syntax for dealing with a space in a string?

    Thanks



    By the way, this is the JS error I get in Firebug:
    
    targetdiv is null
    inlineMsg("fullname", "You must enter your full name.", 2)form_validator.js (line 70)
    validate(a.btn)form_validator.js (line 17)
    onclick(click clientX=1252, clientY=489)8D1OtsKP...zJw%3D%3D (line 3)
    [Break on this error] targetdiv.focus();
    
    Code (markup):

     
    fri3ndly, Dec 30, 2008 IP
  2. fri3ndly

    fri3ndly Active Member

    Messages:
    111
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    60
    #2
    Sorted

    I was calling an incorrect variable :rolleyes:
     
    fri3ndly, Dec 30, 2008 IP