# Text Changed Problems

**URL:** <https://forum.kirupa.com/t/text-changed-problems/320924>\
**Category:** flash\
**Created:** [April 5, 2011, 6:23pm UTC](https://forum.kirupa.com/t/text-changed-problems/320924 "2011-04-05T18:23:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rhanna2](https://avatars.discourse-cdn.com/v4/letter/r/c89c15/32.png) [@rhanna2](https://forum.kirupa.com/u/rhanna2)\
**Post date:** [April 5, 2011, 6:23pm UTC](https://forum.kirupa.com/t/text-changed-problems/320924/1 "2011-04-05T18:23:03Z")

</div>

I want to develop code that does the following:

(1) evaluate the information the user types into an input text field that is called prCv  
(2) when there are 2 digits in the text field, I want the cursor to automatically move to the first position of the next text field, which is called pkgNum  
(3) if the user typed 01 in the prCv field, I want the text color to change to green and display a message to Type 70 in the PKG NO field.  
(4) if the user typed anything other than 01 in the prCv field, I want the text color to change to red and display an error message.

This code is not doing all that I want it to do. Any help would be greatly appreciated!

prCv.addEventListener(TextEvent.TEXT\_INPUT, textChanged);

function textChanged(e:TextEvent) {  
var x = prCv.text;  
if (prCv.length \> 1){  
pkgNum.setSelection(0,0);}  
if (x == “01”){  
prCv.textColor = 0x00FF00;  
messageBox.text = “Type 70 in the PKG NO field.”  
}  
else if (x != “01”){  
prCv.textColor = 0xFF0000;  
messageBox.text = “The correct prior coverage indicator is 01. Please correct this error.”;  
}  
if (prCv.length \<= 1){  
messageBox.text = “Type 01 in the PRCV field.”;  
}  
}
