Wednesday, January 16, 2008

Restrict Alphabet Input In TextBox Using Regular Expression

<html>
<head>

    <script language="javascript">
        function blockChar() {
            var str = document.getElementById('txt').value;
            str = str.replace(/[^\d]*/g, '');
            document.getElementById('txt').value = str;
        }
    </script>

</head>
<body onload="javascript:document.getElementById('txt').focus();">
    <input type="text" id='txt' onkeyup="blockChar();" />
</body>
</html>

2 comments:

  1. Nice Programs.
    Really,Helpful a lot to me

    Thanks & Regards
    Sushant

    ReplyDelete
  2. I would like to ask a query that how to enter hindi character in textbox in asp.net

    ReplyDelete