首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Adobe LiveCycle JavaScript if-Adobe功能?

Adobe LiveCycle JavaScript if-Adobe功能?
EN

Stack Overflow用户
提问于 2014-12-22 21:59:29
回答 1查看 1K关注 0票数 0

我试图做一个非常简单的代码,使一个文本字段具有默认的提示:当鼠标移动时,它们会消失,当鼠标离开时,它们就会出现。我知道我可以用

代码语言:javascript
复制
this.rawValue = "  "
this.rawValue = "Address"

将"Value“部分设置为默认的"Address”。我的问题是,当我键入某项内容时,如果我再次不小心单击该部分,它将返回到默认值。

我遗漏了什么?如果没有输入新文本,我需要它只返回默认值。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-12-29 17:13:11

只要更改它,它就不会编辑文本,如果用户已经输入任何内容。

在滑鼠事件中:

代码语言:javascript
复制
//if the text is the default text, hide it on mouseover.
if (this.rawValue == "Address") this.rawValue = "";

在mouseExit事件中:

代码语言:javascript
复制
//if the text is empty, replace it with the default when the user exits the field.
if (this.rawValue == "" || this.rawValue == null) this.rawValue = "Address";

我会考虑将其放在普通的enter/exit事件中,而不是鼠标特定的事件中,因为一些用户可能会使用选项卡键导航表单。

另外,不要使用空格来表示空,只需使用"“。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27611051

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档