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, ''); }); 

fiddle


Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -