Check String whether it contains only Latin characters?

前端 未结 6 1939
感动是毒
感动是毒 2021-01-01 21:36

Greetings,

I am developing GWT application where user can enter his details in Japanese. But the \'userid\' and \'password\' should only contain English characters(L

6条回答
  •  春和景丽
    2021-01-01 22:03

    There might be a better approach, but you could load a collection with whatever you deem to be acceptable characters, and then check each character in the username/password field against that collection.

    Pseudo:

    
    foreach (character in username)
    {
        if !allowedCharacters.contains(character)
        {
            throw exception
        }
    }
    

提交回复
热议问题