简体   繁体   English

Adobe LiveCycle JavaScript if-else函数?

[英]Adobe LiveCycle JavaScript if-else function?

I am attempting to do VERY simple code to have a text field have default hints that when moused over, they disappear, and when the mouse leaves, they reeappear. 我正在尝试做一个非常简单的代码,以使文本字段具有默认的提示,即,将鼠标悬停时,它们会消失,而当鼠标离开时,它们会重新出现。 I know I can accomplish this with 我知道我可以做到

this.rawValue = "  "
this.rawValue = "Address"

with the "Value" section set at default "Address". “值”部分设置为默认的“地址”。 MY PROBLEM, is that when I type something, if I accidently mouse over the section again, it reverts back to the default value. 我的问题是,当我键入某些内容时,如果我不小心再次将鼠标悬停在该部分上,它将恢复为默认值。

What am I missing? 我想念什么? I need it to only return to the default value if new text isn't entered. 我需要它仅在未输入新文本的情况下才返回默认值。

Just change it so it does not edit the text if the user has entered anything. 只需对其进行更改,以便在用户输入任何内容时都不会编辑文本。

in mouseover event: 在鼠标悬停事件中:

//if the text is the default text, hide it on mouseover.
if (this.rawValue == "Address") this.rawValue = "";

in mouseExit event: 在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";

I'd consider putting this in normal enter/exit events instead of the mouse-specific ones, because some users may use the tab key to navigate the form. 我考虑将其置于普通的进入/退出事件中,而不是鼠标特定的事件中,因为某些用户可能会使用Tab键浏览表单。

Also, don't use spaces to signify empty, just use "". 另外,请勿使用空格来表示为空,而应使用“”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM