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

How do I check if a textbox has no characters in it?

Asked by 9 years ago

I have a custom chatbar and I have an if statement, but I don't know exactly what code I need for it.

I've tried just about every page of the wiki and nothing.

For example:

1if (chat doesnt have just '' or ' ') then
2--do stuff
3else
4(run code)
5end

2 answers

Log in to vote
0
Answered by 9 years ago

You would check the Text property of the TextBox or TextLabel, example;

1local TextBox = --Define this.
2if TextBox.Text == "" then
3elseif TextBox.Text ~= "" then
4end

If this helps, please accept my answer, it gives us both rep!

Ad
Log in to vote
0
Answered by
yumtaste 476 Moderation Voter
9 years ago

The text property is used to determine what text is in a TextBox or TextLabel.

Your question is asking if you can determine if there's any text in a TextBox. Here's how you'd do it:

1local textBox = --define textBox here
2 
3if textBox.Text ~= "" then --this checks to see if the TextBox's text is not blank, i.e. if there's any letters in it
4--run code
5end

Answer this question