2016-06-28 41 views
1

我無法驗證djNumberTextBox類型中的字段。我需要知道這個領域有價值。 我在下面嘗試過,但如果字段爲空或不空白,我無法管理。djNumberTextBox在XPages中的驗證

//var cFld = dijit.byId("#{id:Total}"); 
var aFld = dojo.byId("#{id:Total}"); 
if (aFld!= "") 
{ 
    alert("Please fill the field"); 
    return false; 
} 

回答

1

您的代碼適用於我。

但是,最好使用djNumberTextBox控件的屬性required="true"和設置郵件文本dojoAttribute:「請填寫領域的」

<xe:djNumberTextBox 
    id="Total" 
    value="#{sessionScope.test}" 
    required="true"> 
    <xe:this.dojoAttributes> 
     <xp:dojoAttribute 
      name="missingMessage" 
      value="Please fill the field!" /> 
    </xe:this.dojoAttributes> 
</xe:djNumberTextBox> 

它測試了在客戶端價值並顯示信息如果該值爲空。而不是一個醜陋的警報框,你會得到這樣的消息就在你的輸入字段旁邊:enter image description here

+0

謝謝你的工作很好。我在CSJS中進行了所有字段的驗證。這就是我問:)但你的答案看起來更好,因爲視覺:)) –