Return to Snippet

Revision: 8962
at October 15, 2008 10:23 by jamesming


Initial Code
<html>
<head>
<script>
function countLines(theArea){
  var theLines = theArea.value.replace((new RegExp(".{"+theArea.cols+"}","g")),"\n").split("\n");
  if(theLines[theLines.length-1]=="") theLines.length--;
  theArea.form.lineCount.value = theLines.length;
}
</script>
</head>
<body>
<form>
<textarea name="myText" onKeyUp="countLines(this)" cols="10" rows="10">
</textarea>
<br>
Lines:
<input type=text name="lineCount" size="2" value="0">
</form>
</body>
</html>

Initial URL
http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_21378738.html

Initial Description


Initial Title
Count lines in textarea

Initial Tags


Initial Language
JavaScript