Tuesday, 16 October 2012

Allow Numeric


Java Script Validation allow Only Alpha Numeric


<script type="text/javascript">
        $(function () {
            $('input.alpha[$id=tb1]').keyup(function () {
                if (this.value.match(/[^a-zA-Z0-9 ]/g)) {
                    this.value = this.value.replace(/[^a-zA-Z0-9 ]/g, '');
                }
            });
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div class="bigDiv">
        <h2>Allow Only Alphanumeric Characters in a TextBox</h2>
        <asp:TextBox ID="tb1" runat="server" class="alpha"
            Text="Try entering Non alphanumeric char"
            ToolTip="Try entering Non alphanumeric char"/>
         <br /><br />
         Tip: Examples of some non-alphanumeric characters <br />
         are ~!@~#$%^&* and so on.
    </div>
    </form>
</body>

No comments:

Post a Comment