# Restrict Input text via width of textbox

**URL:** <https://forum.kirupa.com/t/restrict-input-text-via-width-of-textbox/319162>\
**Category:** flash\
**Created:** [February 10, 2011, 3:18pm UTC](https://forum.kirupa.com/t/restrict-input-text-via-width-of-textbox/319162 "2011-02-10T15:18:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kill\_robot\_kill](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/kill_robot_kill/32/359_2.png) [@kill\_robot\_kill](https://forum.kirupa.com/u/kill_robot_kill)\
**Post date:** [February 10, 2011, 3:18pm UTC](https://forum.kirupa.com/t/restrict-input-text-via-width-of-textbox/319162/1 "2011-02-10T15:18:49Z")

</div>

I’d like to restrict the amount a user can type into a textbox based on the width of an existing textbox on the stage. I played around with the max chars but when you type something like a ‘W’ it is considerably wider than something like a ‘i’ (current font is 19px vs 4px wide). I was playing around with .textWidth, but wasn’t sure how to use that value to restrict the textbox.  
any help would be and is appreciated.  
thx
