javascript - Allow only numbers to be typed in a textbox - Stack Overflow

PHOTO EMBED

Fri Oct 28 2022 19:12:22 GMT+0000 (Coordinated Universal Time)

Saved by @mayur #javascript

function isNumber(evt) {
    evt = (evt) ? evt : window.event;
    var charCode = (evt.which) ? evt.which : evt.keyCode;
    if (charCode > 31 && (charCode < 48 || charCode > 57)) {
        return false;
    }
    return true;
}
content_copyCOPY

https://stackoverflow.com/questions/7295843/allow-only-numbers-to-be-typed-in-a-textbox