Friday, April 13, 2018

Count how many letters in String in JavaScript

In this article I would like to share with you a sample program that will ask the user to give a string and then it will count how many letters in the given string.

I am currently accepting programming work, it project, school programming projects , thesis and capstone projects, IT consulting work and web development work kindly contact me in the following email address for further details. Thank you.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.




Sample Program Output


Program Listing

letterscount.html

<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
</head>
<body>
<p align="left">Count how many letters in String in JavaScript<br>
</p>
<div align="left">
  <script language="JavaScript"> 
function cal(str)
    re=/[a-z & A-Z]/g;  
    if(re.test(str))       
    return str.match(re).length 
    else 
    return 0 
</script> 
<input onBlur="alert(cal(this.value) )">
<input type="button" value="Count Letters">
</div>
</body> 
</body>
</html>



No comments:

Post a Comment