Control to put the IP Address

Last post 07-07-2009 6:18 AM by shahed.kazi. 5 replies.

Sort Posts:

  • Control to put the IP Address

    07-02-2009, 6:27 AM

     Hello All,

    I have an application that is made on asp.net and have also used Java Script

    Here, I have a form that is made where I can put IP Address.

    This is a Infragistics WebMaskEdit control

    I wish to have the functionality where when I put a point (.), the cursor moves from one to another.

    Eg: 192.168.20.225, here after 192, if I put a dot(.), the cursor should move to the next part where I can type 168

    Is this Possible ??

    Any help is appreciated

    Praveen

     

  • Re: Control to put the IP Address

    07-02-2009, 9:43 AM
    • Star
      10,272 point Star
    • chintanpshah
    • Member since 11-19-2008, 5:39 AM
    • Ahmedabad
    • Posts 1,834

    Better to post this at: http://forums.infragistics.com/ 

    Hope this helps...

    Don't forget to mark as answer, if it helps
  • Re: Control to put the IP Address

    07-02-2009, 9:44 AM
    • Star
      8,023 point Star
    • satalaj
    • Member since 11-28-2007, 12:41 AM
    • Pune
    • Posts 1,592

     Do something like this.
    Add 4 text boxes.
    On first three text box control OnKeyUp event call a javascript and pass currunt control instance "this".
    In javascrupt function find the length of text in current control if it is greater than 3
    set focus to next text box.

  • Re: Control to put the IP Address

    07-02-2009, 12:22 PM
    Answer

    Yes, some thing like this...

    <asp:TextBox ID="TextBox9" runat="server" MaxLength="3" onkeyup="SetFocus(this)">

    </asp:TextBox><asp:TextBox ID="TextBox10" runat="server" MaxLength="3"></asp:TextBox>

    <script type="text/javascript">

    function SetFocus(txt)

    {

    if (txt.id.indexOf("TextBox9") != -1 && txt.value.length == 3)

    {

    document.getElementById("<% =TextBox10.ClientID%>").focus(); 

    }

    </script>

    Regards,
    Ram Reddy Mekha, +91-994-840-4315
    http://abhiramreddymekha.blogspot.com

    Please Mark as Answer if the post helps you.
  • Re: Control to put the IP Address

    07-07-2009, 6:07 AM
    Answer

    Hi praveen,

    You can capture the 'onkeyup' event and judge the keycode value and set 'focus' for the control.

    Please check the following example:

    <input id="txtIp1" type="text" onkeyup="jump1(this)"/>
                <input id="txtIp2" type="text" onkeyup="jump2(this)"/>
                <input id="txtIp3" type="text" onkeyup="jump3(this)"/>

    <script type="text/javascript">
        function jump1()
        {
                if(event.keyCode==110)
                    {
                        document.getElementById("txtIp1").value=document.getElementById("txtIp1").value.substring(0,document.getElementById("txtIp1").value.length-1);
                        document.getElementById("txtIp2").focus();
                    }
        }
        function jump2()
        {  
                if(event.keyCode==110)
                {
                    document.getElementById("txtIp2").value=document.getElementById("txtIp2").value.substring(0,document.getElementById("txtIp2").value.length-1);
                    document.getElementById("txtIp3").focus();
                }   
        }
        </script>

    Sincerely,
    Hua Jun Li
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
  • Re: Control to put the IP Address

    07-07-2009, 6:18 AM
    • Star
      11,839 point Star
    • shahed.kazi
    • Member since 07-08-2008, 10:15 PM
    • Sydney, Australia
    • Posts 2,328
Page 1 of 1 (6 items)