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
Post a Comment