replaced charCode by keyCode. On every browser, keyCode is filled

with the Unicode Character Code when used in keypress.
charCode is only supported in some browsers.
This commit is contained in:
Mark Schmale 2010-12-13 11:47:57 +01:00 committed by root
parent 390587777f
commit f5038cdc3c

View file

@ -11,8 +11,8 @@ var Validation = {
},
events: {
usernameKeypress: function(evt) {
if(evt.charCode === 0) { return; }
if(!Validation.rules.username.characters.test(this.value + String.fromCharCode(evt.charCode))) {
if(evt.keyCode === 0) { return; }
if(!Validation.rules.username.characters.test(this.value + String.fromCharCode(evt.keyCode))) {
evt.preventDefault();
}
}