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>
Reactions

Post a Comment

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

Please do not post any spam link in the comment box😊

Emoji
(y)
:)
:(
hihi
:-)
:D
=D
:-d
;(
;-(
@-)
:P
:o
:>)
(o)
:p
(p)
:-s
(m)
8-)
:-t
:-b
b-(
:-#
=p~
x-)
(k)

Close Menu