SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    always learning . . .
    Join Date
    Nov 2003
    Location
    UK
    Posts
    821
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    if to check if field filled

    Hi i have an if structure checking to see of the fields have been filled in.
    On the text fields though there is no value so how can i check to see if nothing there which would mean aint been filled in.
    i tried

    if(variable = ""){
    bla bla bla ..............
    }

    doesnt work, please advise

  2. #2
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    '=' is the assignment operator. You need to use the equality comparison operator:
    Code:
    if (myTextField.value == "") {
    }
    else {
    }
    Depending on what is required in the text fields, you might want to try something like...
    Code:
    if (myTextField.value.length < 5) {
      alert('invalid');
    }
    else {
    }

  3. #3
    always learning . . .
    Join Date
    Nov 2003
    Location
    UK
    Posts
    821
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yeh i knew the ==
    > mess up in last post!

    as for the second way, that may just do the trick! becuase just saying "" donest do any thing!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •