how do i block or restrict special characters from input fields with jquery? -


how block special characters being typed input field jquery?

a simple example using regular expression change allow/disallow whatever like.

$('input').on('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;     } }); 

Comments

Popular posts from this blog

sql - can we replace full join with union of left and right join? why not? -

javascript - Parallax scrolling and fixed footer code causing width issues -

iOS: Performance of reloading UIImage(name:...) -