# Test is something exists and then remove

**URL:** <https://forum.kirupa.com/t/test-is-something-exists-and-then-remove/320233>\
**Category:** flash\
**Created:** [March 17, 2011, 2:20pm UTC](https://forum.kirupa.com/t/test-is-something-exists-and-then-remove/320233 "2011-03-17T14:20:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![aerahn](https://avatars.discourse-cdn.com/v4/letter/a/7ba0ec/32.png) [@aerahn](https://forum.kirupa.com/u/aerahn)\
**Post date:** [March 17, 2011, 2:20pm UTC](https://forum.kirupa.com/t/test-is-something-exists-and-then-remove/320233/1 "2011-03-17T14:20:18Z")

</div>

This is something I would think would be easy, but here’s my dilemma: I am trying to see if a textfield exists on the stage and if it does, I want to remove it. I am trying to do it using the code below, but if the textfield doesn’t exist I get an error because I’m tring to remove something that isn’t there. I’m sure there is a simple way to do this and I would appreciate any suggestions. Thanks!

if (stage.contains(cctextBox)) {  
removeChild(cctextBox);  
}
