Hi
I want to disable users from entering a character into a HTML text input field that isnt a letter or number.
This exact functionality can be seen on the Twitter signup page (username field) https://twitter.com/signup.
Im trying to write this in jQuery. But i need to be able to grab the incomming keypress event value to test which key was pressed and if its value is acceptable.
Here's the code:
<input type="text" id="username" name="username" />
<script type="text/javascript">
$("#username").keypress(function(event){
// Get the keypress value
// ...?
// If the keypress value is illegal then disable it
if (...){
event.preventDefault();
}
});
</script>