[CLOSED] Keep EmptyText on Focus

  1. #1

    [CLOSED] Keep EmptyText on Focus

    Hi!

    Is it possible to keep the empty text on focus, when no text is entered.

    Sample:
    http://mail.live.com

    Thanks
    Last edited by Daniil; Dec 12, 2012 at 11:03 AM. Reason: [CLOSED]
  2. #2
    Hello!

    Look at the following example. It uses HTML 5 attribute placeholder but unfortunately IE doesn't support this attribute http://www.w3schools.com/html5/att_i...laceholder.asp :

    <%@ Page Language="C#" %>
      
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.NET Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            <script>
                Ext.override(Ext.form.TextField, {
                    applyEmptyText : function(){
                        if(this.rendered && this.emptyText && this.getRawValue().length < 1 && !this.hasFocus){
                            if ('placeholder' in document.createElement('input')) {
                                this.el.dom.placeholder = this.emptyText;
                            } else {
                                this.setRawValue(this.emptyText);
                                this.el.addClass(this.emptyClass);
                            }
                        }
                    }
                });
            </script>
            <ext:TextField runat="server" FieldLabel="TestField" EmptyText="Enter...">
                <Listeners>
                </Listeners>
            </ext:TextField>
        </form>
    </body>
    </html>
    Last edited by Daniil; Dec 07, 2012 at 5:32 AM. Reason: Corrected the link
  3. #3
    They, Microsoft, did something different. Mail.live.com emptytext on focus works with ie6, ie7, ie8...

    I think it just ExtJs limitation.

    Thanks
    Last edited by SouthDeveloper; Dec 11, 2012 at 11:14 PM.
  4. #4
    Yes, they are using a div block with placeholder text above a field.

    Click image for larger version. 

Name:	live.PNG 
Views:	89 
Size:	21.4 KB 
ID:	5263
  5. #5
    Go it!

    Thanks

Similar Threads

  1. [CLOSED] EmptyText GridPanel
    By osef in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Sep 04, 2012, 6:45 PM
  2. EmptyText coming across as Text
    By dbassett74 in forum 1.x Help
    Replies: 6
    Last Post: Feb 12, 2011, 1:59 PM
  3. [CLOSED] NumberField EmptyText
    By jeybonnet in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Oct 27, 2010, 7:30 AM
  4. [1.0] Field EmptyText
    By Timothy in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Mar 11, 2010, 3:47 PM
  5. Replies: 2
    Last Post: Apr 01, 2009, 9:41 AM

Posting Permissions