jquery - Using Regex to allow disallow text -
i trying use regex limit characters alphabets , numbers
$('#textbox').on("keypress", function (e) { var regex = new regexp("^[a-za-z0-9]+$"); // how proceed? });
however not sure how proceed now? how handle copy paste?
the input
event should capture keys, pasting , other inputs etc. in newer browsers, , it's matter of replacing isn't aplhanumeric character or number in value.
i use /w
, allows underscores , few other characters, filters out other characters aren't alphanumeric or numbers
$('#textbox').on("input", function (e) { this.value = this.value.replace(/\w/g, ''); });
Comments
Post a Comment