Blur is not working for Text Field in ext.net 2.5

  1. #1

    Blur is not working for Text Field in ext.net 2.5

    Hi ,
    Migrated application on ext.net 2.5 from 1.1 .In Breaking changes #117 mentioned that
    The Text Field Change event is now fired when a user is typing, not just on blur.
    But requirement was based on text field length , have to set the other text field enable or disable

    Below is the code for same

    <ext:TextField ID="txtA" runat="server" FieldLabel="Artifact URL" LabelAlign="Left"
                                                    LabelWidth="65" Width="375" EmptyText="Type in the actual path."
                                                    MaxLength="500" MaskRe="[^*%<>]">
                                                    <Listeners>                                                                                                      
                                                        <Focus Handler="#{txtB}.setDisabled(false);" />                                                
                                                         <Blur Handler="setEnable(this)" />                                                
                                                    </Listeners>
                                                   
                                                </ext:TextField>
                                                <ext:TextField ID="txtB" runat="server" FieldLabel="Text to Display" LabelAlign="Left"
                                                    LabelWidth="80" Width="425" EmptyText="Type in the text to display."
                                                    MaxLength="80" MaskRe="[^*%<>]" Disabled="true">
                                                </ext:TextField>
    and javascript code is as beloe
     var setEnable = function(url) {
                if (url.el.dom.value != "") {
                     #{txtB}.setDisabled(false);          
                     }
                     else
                     {
                     #{txtB}.el.dom.value = "";
                     #{txtB}.EmptyText="Type in the text to display.";
                     #{txtB}.applyEmptyText(); 
                     #{txtB}.setDisabled(true);
                     };
    
                } ;
    previously it was working fine but now unable to validate the field .

    Please suggest ! Thanks in advance.
  2. #2
    Hi @Sangeeta,

    Hope this helps.

    Example
    <%@ Page Language="C#" %>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
    
            <ext:TextField ID="TextField1" runat="server">
                <Listeners>
                    <Change Handler="App.TextField2.setDisabled(newValue.length === 0);" />
                </Listeners>
            </ext:TextField>
    
            <ext:TextField ID="TextField2" runat="server" Disabled="true" />
        </form>
    </body>
    </html>
  3. #3
    @Daniil,

    Thanks for your quick response.

    Its working fine to set disable the text field . But I failed to set the Empty Text/Watermark with same method, requirement is as mentioned in my first previous mail.

    Please suggests if there is any syntax change to set empty Text with JS in 2.5 .

    Thanks in advance.
  4. #4
    This appears to be working.
    App.TextField1.emptyText = "Some empty text";
    App.TextField1.applyEmptyText();
  5. #5
    @ Daniil,

    I have been tried the below code.
    Last edited by geoffrey.mcgill; Nov 19, 2014 at 4:50 AM.
  6. #6
    @ Daniil,

    Thanks for your response , I have been tried the below code.

    Previously the same code was working, the requirement is if user deletes the value from first text field then second text field value should be swiped out with water mark and also set as disabled (like page load at first time).

    var setEnable = function(url) {
               if (url.value.length === 0) {
                    #{txtB}.value = "";
                    #{txtB}.EmptyText="Type in the text to display.";
                    #{txtB}.applyEmptyText();
                    #{txtB}.setDisabled(true);                
                    }
                    else
                    {
                    #{txtB}.setDisabled(false);    
                    };
      
               } ;
    Note- Able to set disabled the text field but failed to set the empty text
    Please suggest!

    Thanks in advance.
    Last edited by geoffrey.mcgill; Nov 19, 2014 at 4:51 AM.
  7. #7
    Please clarify have you tried my code? It does work.

    As for this
    #{txtB}.value = "";
    I would use:
    #{txtB}.clear();
  8. #8
    @Daniil,

    Thanks Daniil :). Yes I have tried the above code with text field clear() method its working fine.

    May be previously i was setting it value="" that was not working to reset the empty text.

    I also tried the below suggested solutions.

    http://forums.ext.net/showthread.php...-set-EmptyText

    Its fixed now . Please mark thread as closed

Similar Threads

  1. Text Field Focus fires blur automatically
    By rishu in forum 2.x Help
    Replies: 1
    Last Post: Apr 01, 2013, 10:46 PM
  2. Replies: 2
    Last Post: Nov 09, 2012, 3:23 PM
  3. Replies: 4
    Last Post: Jul 01, 2012, 3:04 AM
  4. Text Field issue
    By paddy in forum 1.x Help
    Replies: 0
    Last Post: Jul 26, 2011, 7:16 AM
  5. Replies: 2
    Last Post: Feb 17, 2010, 9:47 AM

Tags for this Thread

Posting Permissions