How to prevent invalid characters from being typed into input fields
To prevent it from being set in the first place, you can return false on the keydown event handler, thus preventing the event from propagating any further. I wrote the example below using jQuery, but you can use the same function when binding traditionally. Though it’s important to validate on the server-side as well, client-side … Read more