2013-04-25 73 views
0

如何动态地显示在一个文本框点击/有什么价值,当我删除文本框的内容,该消息应该消失动态显示时,文本框中单击

+0

你试图完成的任务,那该多好?这是一种验证吗? – sha 2013-04-25 19:09:07

+0

不是验证。一旦我完成向我的文本框提供值时,必须在文本框旁边显示警告消息,并且一旦我清除了该字段,警报消息也应该被清除。 – 2013-04-26 04:39:07

回答

0

您可以使用监听器消息的消息文本字段。我没有测试下面的代码,但你可以尝试类似的东西。

{ 
    xtype: 'textfield', 
    messageTip: undefined, 
    listeners: { 
     afterrender: function(text) { //Textfield doesn't have a click even't so use afterrender to put a click event on the element 
      //U can use text.inputEl.on({ aswell to only get the input element and not the label 
      text.getEl().on({ 
       click: function() { 
        //Create tip here 
        text.messageTip = Ext.create('Ext.tip.Tip', { 
         //Configuration 
        }).show(); 
       } 
      }); 
     }, 
     keypress: function(text) { 
      if (text.getValue() == '') { 
       //hide the message 
       text.messageTip.hide() 
      } 
     } 
    } 
} 
0

您可以使用文本域 '变' 听众:

{ 
    xtype: 'textfield', 
    listeners : { 
     change: function(field, newValue, oldValue, options)) { 
        if(newvalue!=''){ 
         Message=Ext.create('Ext.tip.ToolTip', { 
         closable:true, 
         hideDelay : 3000, 
         padding: '0 0 0 0', 
         maxWidth:400, 
         width:800, 
         html: ".......", 
         }).showAt([x, y]); 
         } 
        else Message.hide(); 
        } 
       } 
} 
相关问题