输入字段中的默认文本 [英] default text in input field

查看:92
本文介绍了输入字段中的默认文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道它是否有一个特殊的名称,但有一个很简单的方法可以在输入字段中设置默认文本,如果文本框为空,它会在焦点上消失并重新出现在模糊处吗?

I don't know if this has a special name for it, but is there a nice easy way to set default text in an input field which disappears on focus and reappears on blur if the textbox is empty?

推荐答案

这个词是 WATERMARK

the word is WATERMARK


  1. http://plugins.jquery.com/project/Watermark

  2. http://digitalbush.com/projects/watermark-input-plugin/

  3. http://cysemic.com/2008/12/very-simple-textbox -watermark-using-jquery /

  1. http://plugins.jquery.com/project/Watermark
  2. http://digitalbush.com/projects/watermark-input-plugin/
  3. http://cysemic.com/2008/12/very-simple-textbox-watermark-using-jquery/

我鼓励使用插件,除非你有足够的时间开发和测试。编写此代码时需要注意许多问题和副作用。

I encourage to use a plugin, unless you have plenty of time developing and testing. There are many issues and side-effects to take notice of when writing this code.


  • 当字段包含时,将字段验证为空水印文字。
    因此将水印文本与输入文本区分开来。

  • 不提交水印文本。

  • 阻止用户输入水印文本本身:)

  • 为水印文字设置样式。

  • 等等....

  • Validate the field as 'empty' when it contains the watermark text. Thus distinguish the watermark text from inputted text.
  • Not submitting the watermark text.
  • Prevent the user to type in the watermark text itself :)
  • Styling the watermark text.
  • etc, etc....

这篇关于输入字段中的默认文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆