How can I implement Stack Overflow-like watermarks in forms?

后端 未结 5 1820
天涯浪人
天涯浪人 2020-12-28 10:28

I remember seeing a tutorial somewhere that talks of how to style your input forms in a more “usable” way.

Essentially, you have a placeholder value and when you ent

5条回答
  •  太阳男子
    2020-12-28 10:37

    You may want to start from this:

     
    

    You should probably tweak the above to use JavaScript functions in such a way not to repeat your hint string three times, but I hope this can get you going in the right direction.

    I also noticed that the "Join Now" forms at vark.com also set the cursor position to the start of the text box instead of leaving it at the end. This can be bit tricky to make it work cross-browser, but you may want to check the solution proposed in the following article by Josh Stodola:

    • Setting Cursor Position in a Textbox or TextArea with Javascript

提交回复
热议问题