cocostudio textfield输入内容怎么区分字母或者数字?我的办法很简单,就是通过转换成ASSIC码比较。
local mystring = textfield:getStringValue()
function LoginUI:isNumberOrCharacter(mystring)
for i = 1,#mystring do
local account = string.sub(mystring,i,i)
local temp = string.byte(account)
if 48 <= temp and temp <= 57 then
elseif 65<= temp and temp <= 90 then
elseif 97 <= temp and temp <= 122 then
else
cclog("输入包含非数字、字母的字符,不符合规则,请重新输入")
return false
end
end
end
