1) onkeyup send textarea values to script
2) converts textarea value to array
3) loops thru the array
4) uses regex to check if its an email address
5) changes inner html of recipient div

commented: Thanks for the sharing! +12
<script>
function countaddresses(obj){
lineas = 0;
var string = obj.value;
var array = string.split('\n');
var regMail = /^([_a-zA-Z0-9-]+)(\.[_a-zA-Z0-9-]+)*@([a-zA-Z0-9-]+\.)+([a-zA-Z]{2,3})$/;

 for (i = 0; i < array.length; i++) {
 

		if(regMail.test(array[i]) == true) {

			lineas++;

		}
}

document.getElementById('lemails').innerHTML=lineas;
}
</script>
<textarea name="emails" class="widel" onkeyup="countaddresses(this)"></textarea>
			<div id="lemails"></div>

Just a tip: your regex does not work on TLD's larger than three characters (.info, .museum)

Just change var regMail = /^([_a-zA-Z0-9-]+)(\.[_a-zA-Z0-9-]+)*@([a-zA-Z0-9-]+\.)+([a-zA-Z]{2,3})$/; to

var regMail = /^([_a-zA-Z0-9-]+)(\.[_a-zA-Z0-9-]+)*@([a-zA-Z0-9-]+\.)+([a-zA-Z]{2,7})$/;

Member Avatar

LastMitch

Count E-mails in textarea

This is a nice simple codesnippet. it does it job to count emails in the textares. Thanks for sharing.