[英]Adobe LiveCycle ES2 JavaScript if-else, else not working
[英]Adobe LiveCycle JavaScript if-else function?
我正在尝试做一个非常简单的代码,以使文本字段具有默认的提示,即,将鼠标悬停时,它们会消失,而当鼠标离开时,它们会重新出现。 我知道我可以做到
this.rawValue = " "
this.rawValue = "Address"
“值”部分设置为默认的“地址”。 我的问题是,当我键入某些内容时,如果我不小心再次将鼠标悬停在该部分上,它将恢复为默认值。
我想念什么? 我需要它仅在未输入新文本的情况下才返回默认值。
只需对其进行更改,以便在用户输入任何内容时都不会编辑文本。
在鼠标悬停事件中:
//if the text is the default text, hide it on mouseover.
if (this.rawValue == "Address") this.rawValue = "";
在mouseExit事件中:
//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";
我考虑将其置于普通的进入/退出事件中,而不是鼠标特定的事件中,因为某些用户可能会使用Tab键浏览表单。
另外,请勿使用空格来表示为空,而应使用“”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.