Make TextBox Readonly In JavaScript at Keypress Event.

Introduction :

 Hi, Here I will explain how to make TextBox Readonly without using Readonly Property in JavaScript or else in ASP. This Script Coding works Fine in 'KeyPress' Event of the TextBox.
Here Keycode is used for Catching the Keyboard events.Finally this TextBox allows Nothing as a Input even after key is pressed. haven't need any Ajax controls to implement it.

Aspx and javaScript:

<html>
<head runat="server">
    <title>FourthBottle.com</title>
    <script type="text/javascript">
        function AvoidWrite(evt) {
            var charCode = (evt.which) ? evt.which : event.keyCode
            if (charCode < 48 || charCode > 57)
                return false;
            else {
                return false;
             }
        }   
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <asp:TextBox ID="txt1" runat="server" onpaste="return false;" onkeypress="return AvoidWrite(event);" ></asp:TextBox>
    </div>
    </form>
</body>
</html>