I have created a jQuery Plugin which you can download using the following link.
Download Plugin
It considers Enter key character as new line. It works on type, paste and drop text.
Following is the example.
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript" src="MaxLines.min.js"></script>
<script type="text/javascript">
$(function () {
//Normal Configuration
$("#TextBox1").MaxLines({ MaxLines: 2 });
//Specifying the Character Count control explicitly
$("#TextBox2").MaxLines({
MaxLines: 5,
LineCountControl: $('#counter')
});
});
</script>
<textarea id="TextBox1" style="height: 100px; width: 300px">Mudassar Khan</textarea>
<br />
<br />
<textarea id="TextBox2" style="height: 100px; width: 300px"></textarea>
<br />
<br />
Total Lines: <span id="counter"></span>