Skip to main content
Participant
August 17, 2012
Question

How to have a button only accept if text is entered in a text box.

  • August 17, 2012
  • 1 reply
  • 583 views

Ok so I have a game called "DCGame"  and I need help with the guest login. Like when people type a nickname for the login. I would it not to accept no text entered. Could you help me?

This topic has been closed for replies.

1 reply

Ned Murphy
Legend
August 18, 2012

Assign the textfield an instance name and use a condtional to test if the length property of the textfield is not zero.

  if(yourTextFieldName.length > 0){

        //  do whatever

  }

Participant
August 18, 2012

Should I put that code inside the button code or outside.

Ned Murphy
Legend
August 18, 2012

Only you can answer that.  Put it wherever you need to check the textfield.  Ideally, if you are coding in the timeline, all code should be in the main timeline.