Can get jquery watermark to work on forms?

Discussion in 'jQuery' started by misohoni, Apr 15, 2012.

  1. #1
    misohoni, Apr 15, 2012 IP
  2. Basti

    Basti Active Member

    Messages:
    625
    Likes Received:
    6
    Best Answers:
    3
    Trophy Points:
    90
    #2
    Hard to say if you missed something without seeing what you have added ;)

    Properbly wrong path on

    <script type="text/javascript" src="../js/jquery.watermark.js"></script>
    Code (markup):
    ?? ( ../ )
     
    Basti, Apr 16, 2012 IP
  3. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #3
    Are you trying to use this to show a placeholder text in the input-fields? If so, just use HTML. "placeholder=''" is what you're looking for. Like this:

    
    <input type="text" name="username" id="username" value="" placeholder="Type your username/email">
    
    Code (markup):
     
    PoPSiCLe, Apr 17, 2012 IP
  4. misohoni

    misohoni Notable Member

    Messages:
    1,717
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    200
    #4
    Cheers, but with content already in the form box - couldn't someone just submit the form anyway?

    I think Jquery watermark doesn't do this.

    I'm actually trying to copy the same form Namecheap uses at the top of their site...
     
    misohoni, Apr 17, 2012 IP
  5. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #5
    No. The placeholder attribute is not part of what is posted from a form - only values that are posted from a form is the "value"-attribute (or content from textarea and the like). The placeholder is perfectly safe HTML 5, but doesn't work in older browsers. However, for me, that's not an issue, so I chose to use HTML instead, simply because it makes the javascript amount smaller, and hence the page lighter and faster.
     
    PoPSiCLe, Apr 17, 2012 IP
  6. misohoni

    misohoni Notable Member

    Messages:
    1,717
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    200
    #6
    Cheers, but wouldn't jquery watermark be better for you if it works on other browsers...
     
    misohoni, Apr 17, 2012 IP
  7. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #7
    Depends on your need. To get certain (not necessarily this) jQuery functions to work in all browsers, you often have to make different javascript-bits to fit each browser, which increases the amount of javascript immensly. The HTML version is perfectly fine to use, it will show up in browsers supporting the attribute, and will be happily ignored in all other browsers. You should in no way use this as a placement for information or the like of an important nature, just to help users - if a user have javscript turned off, for instance, he will no longer see the placeholder anyway.
     
    PoPSiCLe, Apr 17, 2012 IP
  8. misohoni

    misohoni Notable Member

    Messages:
    1,717
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    200
    #8
    Ok cool, I hear what you're saying thanks.

    Just out of interest, regarding the JS turned off thing - how do companies like GoDaddy and Namecheap manage since there's looks to be using javascript only?
     
    misohoni, Apr 17, 2012 IP
  9. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #9
    Well. The javascript turned off isn't a big deal - most users don't turn off javascript. There are, however, quite a few extensions to popular browsers, for instance Firefox (NoScript) which turns off js, but makes it fairly easy to turn it on if needed.

    If you're gonna make a website, the goal should always be to accomodate as many as possible - which is most easily done by having good, semantically sound, correct HTML (and CSS). The benefit of this (the placeholder-attribute) is that, even though it doesn't validate, since the W3C-validator is a bit flunky on HTML5-bits, it degrades gracefully, and doesn't provide a huge extra file-size-cost.

    I try to make websites that both look and feel good and snappy in modern browsers, but which also work on older versions, albeit maybe with some of the funkyness turned off. It might not look as good, or exactly the same, but that shouldn't be the goal. When a marketing ghoul says "it has to look exactly the same regardless of browser og if the user has a PC or a Mac, mkay?" - just run.
     
    PoPSiCLe, Apr 17, 2012 IP