--string 需要鉴定的字符串
--返回值 true是全数字
function UIBase:judgeIsAllNumber(string, displayCenter)
local isAllNum = false
isAllNum = false
else
--判断是否有其他符号或者文字
local n = tonumber(string)
if n then
-- print("this num is ======= " .. n)
if n<0 then
--是负数,肯定有负号
isAllNum = false
else
local pn = getIntPart(n) --此处为取整数部分参见http://blog.youkuaiyun.com/daydayup_chf/article/details/46351947
-- print("number int part ====== " .. pn)
if pn == n then
-- print("***********************")
isAllNum = true
else
--不相等说明有小数点
isAllNum = false
end
end
else
isAllNum = false
-- print("this string is not a number !!!!!")
end
end
--提示
if isAllNum == false then
-- print("not is all number !!!!!!!!!!!!")
self:inputSysTips(InputIsNumber, displayCenter)
end
return isAllNum
end
--返回值 true是全数字
function UIBase:judgeIsAllNumber(string, displayCenter)
local isAllNum = false
--先屏蔽加号和空格
local s1, e1 = string.find(string, "+")
local s2, e2 = string.find(string, " ")
if s1 ~= nil or e1 ~= nil or s2 ~= nil or e2 ~= nil thenisAllNum = false
else
--判断是否有其他符号或者文字
local n = tonumber(string)
if n then
-- print("this num is ======= " .. n)
if n<0 then
--是负数,肯定有负号
isAllNum = false
else
local pn = getIntPart(n) --此处为取整数部分参见http://blog.youkuaiyun.com/daydayup_chf/article/details/46351947
-- print("number int part ====== " .. pn)
if pn == n then
-- print("***********************")
isAllNum = true
else
--不相等说明有小数点
isAllNum = false
end
end
else
isAllNum = false
-- print("this string is not a number !!!!!")
end
end
--提示
if isAllNum == false then
-- print("not is all number !!!!!!!!!!!!")
self:inputSysTips(InputIsNumber, displayCenter)
end
return isAllNum
end