-
Senior Member
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"); } } }
-
Registered User
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"); } }
-
Senior Member
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?
-
Senior Member
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.
-
Registered User
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|