Wednesday, 30 August 2017

Allow user to enter only numbers in textbox using jquery or javascript

<input type="text" id="numText" runat="server" />


$("#numText").keydown(function (event) {
                    var keycode = event.keyCode;
                    //comparing pressed keycodes
                    if (!(keycode == 8 || keycode == 46) && (keycode < 48
|| keycode > 57)) {
                        return false;
                    }
                    else {
                        return true;
                    }
                });

No comments:

Post a Comment

React Hooks - custom Hook

  v CustomHook Ø React allows us to create our own hook which is known as custom hook. Example – 1 localStorage Demo Step-1 Create ...