# Require Text Input Before Continue & If Statement Malfunctions

**URL:** <https://forum.kirupa.com/t/require-text-input-before-continue-if-statement-malfunctions/332263>\
**Category:** flash\
**Created:** [March 26, 2014, 5:54pm UTC](https://forum.kirupa.com/t/require-text-input-before-continue-if-statement-malfunctions/332263 "2014-03-26T17:54:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jemro](https://avatars.discourse-cdn.com/v4/letter/j/7c8e57/32.png) [@Jemro](https://forum.kirupa.com/u/Jemro)\
**Post date:** [March 26, 2014, 5:54pm UTC](https://forum.kirupa.com/t/require-text-input-before-continue-if-statement-malfunctions/332263/1 "2014-03-26T17:54:23Z")

</div>

I am really working to get this project completed (it’s an online cognitive psychology experiment), and I’m at the stage now of working out bugs and errors. So, I apologize in advance if I post a lot of questions.

Here’s some context on the project. A participant is shown a word and asked to indicate how many times they’ve seen that word throughout the course of the experiment. Responses are restricted to 0-4. If they respond:  
[LIST]  
[_]2-4, they’re asked whether the background colors were the same or different each time they saw the word, and then they select the color of the various backgrounds  
[_]1, they select the color of the background  
[_]0, move on to next item  
[_]blank, require input before continuing  
[/LIST]

I can get the program working correctly if a user responds 1, 2, 3, or 4. The problem is if the response is 0 or blank–the same code fails. If I allow the “0 condition”, below, to execute, it ALWAYS executes, regardless of the value of numberAnswer.

Lastly, I’m at a loss for how to make sure that the user actually enters a value before continuing. I tried if(numberAnswer\*=="", but it would not execute that code correctly. I really appreciate any help you all can offer (as always).

Here’s what I have so far:

```auto
function executePresentationTest ():void{
    //**Unrelated stuff here removed to make code shorter//
    if(i==90)
        {
            gotoAndStop(8);
        }
    else
        {
            txtMainDisplay.text = "How many times was the below word presented (enter a number 0 - 4)?"
            txtWordDisplay.text = testWord*
            stage.focus = txtInput;
            stage.addEventListener(KeyboardEvent.KEY_DOWN, record_responsepres)
            
        }
    }
    
function record_responsepres(evt:KeyboardEvent):void
    {
        if(evt.keyCode== Keyboard.ENTER)
        {
            txtInput.type=TextFieldType.DYNAMIC;
            txtInput.border=false;
            elapsedTime2=getTimer();
            elapsedTime=elapsedTime2-elapsedTime;
            elapsedTime=getTimer();
            numberAnswer*=int(txtInput.text) 
            stage.removeEventListener(KeyboardEvent.KEY_DOWN,record_responsepres);    
            
            {
            if(numberAnswer*=="4" || numberAnswer*=="2" || numberAnswer*=="3")
                {
                    testQuestion();
                }
            else if (numberAnswer*=="1")
                {
                    pickColors();
                }
            /*else if (numberAnswer*=="0");
                {
                    trace("Executing if 0");
                    blackScreen2();
                }*/
            }
        }
    }

```
