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

php - How to add and update images or image url in Volusion using Volusion API -

Laravel mail error `Swift_TransportException in StreamBuffer.php line 269: Connection could not be established with host smtp.gmail.com [ #0]` -

c# SetCompatibleTextRenderingDefault must be called before the first -