简体   繁体   中英

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:

//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.

Also, don't use spaces to signify empty, just use "".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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