Last Updated: February 25, 2016
·
5.421K
· danzkusuma

Filter Alphanumeric in Input with Jquery

Jquery is very handy to catch un-wanted input character from our input form. to make this happend, use this code :

$('input').bind('keypress', function (event) {
        var regex = new RegExp("^[a-zA-Z0-9]+$");
        var key = String.fromCharCode(!event.charCode ? event.which : event.charCode);
        if (!regex.test(key)) {
            event.preventDefault();
            return false;
        }
    });