A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: TextInput box validation help

  1. #1
    Senior Member hts5000's Avatar
    Join Date
    Oct 2007
    Posts
    160

    TextInput box validation help

    I have this form and I need to validate that each TextInput box has data in it and I am having issues with a certain part. There is a section where TextInput boxes are dynamically added into a ScrollPane. There can be anywhere from 1 box to 9999 TextInput boxes. I can validate that these TextInput boxes have no information in them separately however I cannot seem to validate that all the boxes as a whole do not have information in them. For example if there are 3 TextInput boxes and only 2 have info in them I need to know that.

    I am trying to do two things here, if the box is empty I need to change the TextInput box background to yellow (this I can do no problem) and if all the boxes have info in them then I will let the user progress to a different part of the form.

    This is the code that I am using so far. Any help or ideas would be greatly appreciated.

    Actionscript Code:
    if (spProdGroup.getValue() == 1 && quesGroup.getValue() == 1) {
        for (r=1; r<Number(qIDAmount.text)+1; r++) {
            if (qIDAmount.text != "") {
                qIDAmount.setStyle("backgroundColor","0xFFFF33");
            }
            if (sPane.spContentHolder["qId"+r].qestionID.text == "") {
                //This part works just fine
                sPane.spContentHolder["qId"+r].qestionID.setStyle("backgroundColor","0xFFFF33");
                val._visible = true;
            }
            if (qIDAmount.text != "" && sPane.spContentHolder["qId"+r].qestionID.text != "") {
                //This part does not
                trace("All boxes have data");
            }
        }
    }

  2. #2
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    hi,

    Here's the logic you'll have to use:
    Actionscript Code:
    var allBoxesHaveData:Boolean = true;
    if (spProdGroup.getValue () == 1 && quesGroup.getValue () == 1)
    {
        for (r = 1; r < Number (qIDAmount.text) + 1; r++)
        {
            if (qIDAmount.text != "")
            {
                qIDAmount.setStyle ("backgroundColor","0xFFFF33");
            }
            if (sPane.spContentHolder["qId" + r].qestionID.text == "")
            {
                //This part works just fine
                sPane.spContentHolder["qId" + r].qestionID.setStyle ("backgroundColor","0xFFFF33");
                val._visible = true;
            }
            else
            {
                // there is at least a box which doesn't have data
                allBoxesHaveData = false;
            }
        }
       
        if (allBoxesHaveData)
        {
            trace("all boxes have data");
        }
        else
        {
            trace("there is at least a box which doesn't have data");
        }
    }

  3. #3
    Senior Member hts5000's Avatar
    Join Date
    Oct 2007
    Posts
    160
    Thanks nunomira for your help, unfortunately the code did not work. I think it has more to do with the for loop and how long it takes to process. Is there any way to detect the process of a for loop and only execute code when it is done?

  4. #4
    Senior Member hts5000's Avatar
    Join Date
    Oct 2007
    Posts
    160
    nunomira, I apologize. I didn’t see that you check statement was outside of the for loop. Once I took it out of the for loop it worked just fine. Thanks for your help.

  5. #5
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    That's cool!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center