Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How to check if a textbox contains a number?

Asked by
JJ_B 250 Moderation Voter
8 years ago

I just want to know if there is a specific way of doing this.

1 answer

Log in to vote
3
Answered by
XAXA 1569 Moderation Voter
8 years ago

You can use string.match on the string to check if there's a digit/number. string.match returns something if a match is found. Otherwise, it returns nil.

if string.match(Textbox.Text, "%d") then -- %d matches a digit 
    -- TODO: Do something if there is a number in Textbox
end

For more info, read the wiki article for string functions and pattern matching.

Ad

Answer this question