Merge branch 'master' of http://192.168.0.87:10010/r/snxxz_scripts
| | |
| | | return;
|
| | | }
|
| | | int error = 0;
|
| | | if (!SatisfyNameLength(userNameInput.text, out error))
|
| | | if (!UIHelper.SatisfyNameLength(userNameInput.text, out error))
|
| | | {
|
| | | switch (error)
|
| | | {
|
| | |
| | | private void RemoveRoleModel()
|
| | | {
|
| | | m_CreateRoleShow.Dispose();
|
| | | }
|
| | |
|
| | | public bool SatisfyNameLength(string name, out int error)
|
| | | {
|
| | | error = 0;
|
| | | bool pureChinese = Regex.IsMatch(name, "^[\u4e00-\u9fa5]+$");
|
| | | if (pureChinese)
|
| | | {
|
| | | if (name.Length > 5)
|
| | | {
|
| | | error = 1;
|
| | | }
|
| | | else if (name.Length < 2)
|
| | | {
|
| | | error = 2;
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | if (name.Length > 6)
|
| | | {
|
| | | error = 1;
|
| | | }
|
| | | else if (name.Length < 3)
|
| | | {
|
| | | error = 2;
|
| | | }
|
| | | }
|
| | | return error == 0;
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | }
|
| | |
|
| | | int error = 0;
|
| | | if (!SatisfyNameLength(renameInput.text, out error))
|
| | | if (!UIHelper.SatisfyNameLength(renameInput.text, out error))
|
| | | {
|
| | | switch (error)
|
| | | {
|
| | |
| | | });
|
| | |
|
| | | }
|
| | |
|
| | | public bool SatisfyNameLength(string name, out int error)
|
| | | {
|
| | | error = 0;
|
| | | bool pureChinese = Regex.IsMatch(name, "^[\u4e00-\u9fa5]+$");
|
| | | if (pureChinese)
|
| | | {
|
| | | if (name.Length > 5)
|
| | | {
|
| | | error = 1;
|
| | | }
|
| | | else if (name.Length < 2)
|
| | | {
|
| | | error = 2;
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | if (name.Length > 6)
|
| | | {
|
| | | error = 1;
|
| | | }
|
| | | else if (name.Length < 3)
|
| | | {
|
| | | error = 2;
|
| | | }
|
| | | }
|
| | | return error == 0;
|
| | | }
|
| | |
|
| | |
|
| | | }
|
| | | }
|
| | |
| | | content = content.Replace(" ", string.Empty);
|
| | | return content;
|
| | | }
|
| | |
|
| | | public static bool SatisfyNameLength(string name, out int error)
|
| | | {
|
| | | error = 0;
|
| | | bool pureChinese = Regex.IsMatch(name, "^[\u4e00-\u9fa5]+$");
|
| | | var chsCount = GetChsCount(name);
|
| | | var maxlength = pureChinese ? 5 : chsCount > 0 ? 6 : 8;
|
| | | var minlength = pureChinese ? 2 : 3;
|
| | | if (name.Length > maxlength)
|
| | | {
|
| | | error = 1;
|
| | | }
|
| | | else if (name.Length < minlength)
|
| | | {
|
| | | error = 2;
|
| | | }
|
| | | return error == 0;
|
| | | }
|
| | |
|
| | | public static int GetChsCount(string name)
|
| | | {
|
| | | var count = 0;
|
| | | for (int i = 0; i < name.Length; i++)
|
| | | {
|
| | | if (Regex.IsMatch(name[i].ToString(), "[\u4e00-\u9fa5]"))
|
| | | {
|
| | | count++;
|
| | | }
|
| | | }
|
| | | return count;
|
| | | }
|
| | | }
|