Limit the number of lines in an input textfield

/ Published in: ActionScript 3
Save to your folder(s)

I made one adjustment to the code because I was getting one scrolling extra line.

inputfield.textHeight > inputfield.height

inputfield.textHeight >= inputfield.height

Copy this code and paste it in your HTML
  1. var prevText:String;
  2. inputfield.addEventListener(Event.CHANGE, onUpdate);
  4. private function onUpdate(e:Event):void {
  5. if (inputfield.textHeight >= inputfield.height){
  6. inputfield.text = prevText;
  7. }else prevText= inputfield.text;
  8. }


Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.