mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-22 08:20:36 +01:00
only allow alphanumberic charactesr in username
This commit is contained in:
@@ -22,12 +22,13 @@
|
|||||||
if(username.value.length < 3) {
|
if(username.value.length < 3) {
|
||||||
username_notify.innerHTML = 'Username too short';
|
username_notify.innerHTML = 'Username too short';
|
||||||
username_notify.className = 'label label-important';
|
username_notify.className = 'label label-important';
|
||||||
}
|
} else if(username.value.length > 13) {
|
||||||
else if(!usernamevalid) {
|
username_notify.innerHTML = 'Username too long';
|
||||||
|
username_notify.className = 'label label-important';
|
||||||
|
} else if(!usernamevalid) {
|
||||||
username_notify.innerHTML = 'Invalid username';
|
username_notify.innerHTML = 'Invalid username';
|
||||||
username_notify.className = 'label label-important';
|
username_notify.className = 'label label-important';
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
socket.emit('user.exists', {username: username.value});
|
socket.emit('user.exists', {username: username.value});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -86,12 +86,12 @@
|
|||||||
// from http://stackoverflow.com/questions/46155/validate-email-address-in-javascript
|
// from http://stackoverflow.com/questions/46155/validate-email-address-in-javascript
|
||||||
isEmailValid: function(email) {
|
isEmailValid: function(email) {
|
||||||
// var re = /[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/;
|
// var re = /[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/;
|
||||||
var valid = email.indexOf('@') !== -1 ? true : false;
|
var valid = email.indexOf('@') !== -1 ? true : false;
|
||||||
return valid;
|
return valid;
|
||||||
},
|
},
|
||||||
|
|
||||||
isUserNameValid: function(name) {
|
isUserNameValid: function(name) {
|
||||||
return (name && name !== "" && !(/^\s*$/.test(name)));
|
return (name && name !== "" && (/^\w{3,14}$/.test(name)));
|
||||||
},
|
},
|
||||||
|
|
||||||
isPasswordValid: function(password) {
|
isPasswordValid: function(password) {
|
||||||
|
|||||||
Reference in New Issue
Block a user