only allow alphanumberic charactesr in username

This commit is contained in:
Baris Soner Usakli
2013-07-31 12:48:30 -04:00
parent f4fdabd3ca
commit a0a1b14e2e
2 changed files with 7 additions and 6 deletions

View File

@@ -22,12 +22,13 @@
if(username.value.length < 3) {
username_notify.innerHTML = 'Username too short';
username_notify.className = 'label label-important';
}
else if(!usernamevalid) {
} else if(username.value.length > 13) {
username_notify.innerHTML = 'Username too long';
username_notify.className = 'label label-important';
} else if(!usernamevalid) {
username_notify.innerHTML = 'Invalid username';
username_notify.className = 'label label-important';
}
else {
} else {
socket.emit('user.exists', {username: username.value});
}
});

View File

@@ -91,7 +91,7 @@
},
isUserNameValid: function(name) {
return (name && name !== "" && !(/^\s*$/.test(name)));
return (name && name !== "" && (/^\w{3,14}$/.test(name)));
},
isPasswordValid: function(password) {