0

hello friends
I am new to asp.net. does anyone has any sample code of text box on how to limit inputs into four digits and move to next text box and auto decimal
if anyone has a code or knows a good tutorial on how to ,please let me know
id be grateful

3
Contributors
3
Replies
35
Views
4 Years
Discussion Span
Last Post by geniusvishal
0

Another Alternative Using Javascript and Jquery:

MarkUp:

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>

<script type="text/javascript">

    function isNNumeric(e) {

        var isNN = (navigator.appName.indexOf("Netscape") != -1);

        var keyCode = (isNN) ? e.which : e.keyCode;

        //alert(keyCode);

        if (isNN) {

            if (keyCode == 0)

                return true;

        }

        if ((keyCode > 47 && keyCode < 58) || (keyCode == 8) || (keyCode == 9)) {

            return true;

        }

        else {

            if (e.returnValue) {

                e.returnValue = false;

                return false;

            }

            else if (e.preventDefault) {

                e.preventDefault();

                return false;

            }

            this.event.returnValue = false;

            return false;

        }

    }

</script>

<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.js"></script>

<script type="text/javascript">
    $(function () {
        $('#TextBox1,#TextBox2,#TextBox3').keyup(function (e) {
            if ($(this).val().length == $(this).attr('maxlength'))
                $(this).next(':input').focus()
        })
    })
</script>


</head>
<body>
    <form id="form1" runat="server">
    <div>

        <asp:TextBox ID="TextBox1" onkeypress="return isNNumeric(event)" runat="server" 
            MaxLength="4" Width="35px"></asp:TextBox>
        .<asp:TextBox ID="TextBox2" onkeypress="return isNNumeric(event)" 
            runat="server" MaxLength="2" Width="16px"></asp:TextBox>
        <br />
        <br />
        <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
        <br />
        <br />
        <asp:Label ID="lblMsg" runat="server" Font-Bold="True" ForeColor="Red"></asp:Label>

        <br />
        <br />
        Refer this link for other alternative <a href="http://www.mathachew.com/sandbox/jquery-autotab/">here</a></div>
    </form>
</body>
</html>

Code-Behind:

    protected void Button1_Click(object sender, EventArgs e)
    {
        lblMsg.Text = "You Entered: "+TextBox1.Text+"."+TextBox2.Text;
        TextBox1.Text = "";
        TextBox2.Text = "";
    }
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.