It seems that TecHunter has already published almost the same thing, but I was bored and did it.
In 155 characters, instead of 5 characters, "...." is replaced. It has an input to textarea with a character counter, which is updated as you type.
Html
<div> <h2>Input</h2> <textarea id="sampleInput"> It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that </textarea> </div> <div> <label>Character Count:</label> <span id ="charCounter"></span> <div> <h2>Output</h2> <p style="width:100px" id="sampleOutput"></p>
Js
updateOutput(); $('#sampleInput').keyup(function(e){ updateOutput(); }); function updateOutput(){ var sampleInput = $('#sampleInput').val(), sampleInputLength = sampleInput.length; if(sampleInputLength >= 155) { sampleInput = sampleInput.substr(0,150) + "....."; } $('#charCounter').text(sampleInputLength); $('#sampleOutput').text(sampleInput); }
CSS
#sampleInput { width: 400px; height:100px; }
jsfiddle
Jerry source share