Question: I have an app that has a textbox, validation control and a button. The problem is that if someone copies text from a word document inside the textbox, some of the special characters won't be allowed because of the validation control. But if I delete those special characters and we typed them, the validation control works. Is there a way to convert that text to plain text or rich text inside the textbox?

Answer: 
Copy the text into a `visibility: hidden` div with font styles equal to the textarea and a `max-width` that won't let it go beyond your number of columns. If the height of the hidden copy of the text exceeds your limit, remove the text that was added.

The following is *close* to what you need. Unfortunately, it doesn't nix the 5th row (after hitting enter on the 4th row) until you type something on it, and it can leave a couple characters on the 5th row (if you wrap to the 5th row from the 4th row). I'm uncertain how to refine the technique further.

```js
var $measure = $('#measure');
var $input = $('#input');
var $output = $('#measurement');

var existingText = '';
$input.on('keyup', function(event) {
    $measure.html($input.val());
    $output.val($measure.width() + 'x' + $measure.height() + 'px');
    if ($measure.height() > 60) {
        $input.val(existingText.trim());
        $measure.html(existingText.trim());
    }
    existingText = $input.val();
});
```

```css
#measure
{
    position: absolute;
    visibility: hidden;
    height: auto;
    width: auto;
    white-space: pre-wrap;

    /* set font style equal to style of textarea */
    font-family: monospace;
    font-size: 13px;
    letter-spacing: normal;
    line-height: normal;
    word-spacing: 0;
    word-wrap: break-word;
    max-width: 221px;
    border: 1x solid black;
    margin: 2px;
    padding: 2px;
}
```

```html
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<textarea id="input" cols="30" rows="4"></textarea>
<div id="measure"></div>
<br>
<input type="text" disabled="disabled" id="measurement"/>
```
Set maxlength attr to 120

Example link is here

<http://www.w3schools.com/tags/att_textarea_maxlength.asp>