ASPxTextBox – how to accept only numeric data

ASPX
<dx:ASPxTextBox ID=”txtSozNo” runat=”server” Width=”100%” ClientInstanceName=”ttxtSozNo”>
<ClientSideEvents KeyPress=”function(s,e){ fn_AllowonlyNumeric(s,e);}” />
 </dx:ASPxTextBox>

javascript
function fn_AllowonlyNumeric(s, e) {
            var theEvent = e.htmlEvent || window.event;
            var key = theEvent.keyCode || theEvent.which;
            key = String.fromCharCode(key);
            var regex = /[0-9]/;
            if (!regex.test(key)) {
                theEvent.returnValue = false;
                if (theEvent.preventDefault)
                    theEvent.preventDefault();
            }
        }


j


                    theEvent.preventDefault();
            }
        }

Leave a Reply

Your email address will not be published. Required fields are marked *