new login consistency constraint added (no more than 2 consecutive same char or digits)
[brisk.git] / web / room.js
index 38a3d2a..e914fbf 100644 (file)
@@ -491,6 +491,8 @@ function j_tab_act_cont(idx, act)
 
 function j_check_login(login, ret)
 {
+    var cmp;
+
     if (login.length > 12) {
         // FIXME LANG
         ret.ret += (g_lang == 'en' ? "Nickname too long." : "Nickname troppo lungo.");
@@ -502,15 +504,24 @@ function j_check_login(login, ret)
         if ((login[i] >= '0' && login[i] <= '9') ||
             (login[i] >= 'a' && login[i] <= 'z') ||
             (login[i] >= 'A' && login[i] <= 'Z')) {
-            if (old_c != login[i]) {
-                old_c = login[i];
+            if (login[i] >= '0' && login[i] <= '9')
+                cmp = '0';
+            else
+                cmp = login[i];
+
+            if (old_c != cmp) {
+                old_c = cmp;
                 old_ct = 1;
             }
             else {
                 if (old_ct > 2) {
                     // FIXME LANG
-                    ret.ret = (g_lang == 'en' ? "More than two contiguous '" + old_c + "' not allowed." :
-                               "Il nickname contiene più di 2 caratteri '" + old_c + "' consecutivi.");
+                    if (old_c == '0')
+                        ret.ret = (g_lang == 'en' ? "More than two contiguous digits not allowed." :
+                                   "Il nickname contiene più di 2 cifre consecutive.");
+                    else
+                        ret.ret = (g_lang == 'en' ? "More than two contiguous '" + old_c + "' not allowed." :
+                                   "Il nickname contiene più di 2 caratteri '" + old_c + "' consecutivi.");
                     return (false);
                 }
             }
@@ -639,7 +650,7 @@ function mesgtoadm_formtext_hilite(form)
 
 function j_check_email(email, ret)
 {
-    if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,10})+$/.test(email))
+    if (/^\w+([\.-]*\w+)*@\w+([\.-]*\w+)*(\.\w{2,10})+$/.test(email))
         return (true);
     ret.ret += (g_lang == 'en' ? "Invalid email address. " :
                 "Indirizzo e-mail non valido.");