js,restrict,prevent,special,chars,allowed,letters,numbers

Kubilay 9/9/2016 0

This javascript code lets user only enter letters and numbers.

JavaScript
    $('#myinput').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;            
        }
    }); 

Report Bug

Please Login to Report Bug

Reported Bugs

Comments

Please Login to Comment

Comments