簡體   English   中英

Adobe LiveCycle JavaScript if-else函數?

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM