In this sample program, we will show you how to count the capital and small letters in a given sentence using JQuery a JavaScript library.
If you like my work please click the ads on my website to support my work. I will really appreciate your help.
I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details. If you want to advertise on my website kindly contact me also in my email address also. Thank you.
If you like my work please click the ads on my website to support my work. I will really appreciate your help.
I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details. If you want to advertise on my website kindly contact me also in my email address also. Thank you.
My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.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.
Here in Bacolod I also accepting computer repair, networking and Arduino Project development at a very affordable price.
My personal website is http://www.jakerpomperada.com
Sample Program Output
Program Listing
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<title>Count Capital and Small Letters in JQuery</title>
<style>
body{
font-family:arial;
font-size:15px;
font-weight:bold;
}
</style>
<script>
$(function(){
$("#count").click(function(){
if (document.getElementById("str").value == '') {
alert("Textbox is Empty !!! Please provide some string.");
document.getElementById("str").value = "";
document.getElementById("upper_str").value = "";
document.getElementById("lower_str").value = "";
document.getElementById("str").focus();
}
else {
var str1 = document.getElementById("str").value;
var numUpper = str1.length - str1.replace(/[A-Z]/g, '').length;
var numLower = str1.length - str1.replace(/[a-z]/g, '').length;
var result = document.getElementById("upper_str");
var result2 = document.getElementById("lower_str");
result.value = numUpper;
result2.value = numLower;
}
});
});
$(function(){
$("#clear").click(function(){
document.getElementById("str").value = "";
document.getElementById("upper_str").value = "";
document.getElementById("lower_str").value = "";
document.getElementById("str").focus();
});
});
</script>
</head>
<body>
<br><br>
<h3>Count Capital and Small Letters in JQuery</h3>
<br>
Enter a String <input type="text" id="str" name="str" value="" size="30" autofocus/>
<br><br>
<input type="button" name="Submit" id="count" value="Count" title="Click here to count the capital and small letters."/>
<input type="button" name="Submit" id="clear" value="Clear" title="Click here to clear the text box."/>
<br><br><br><br>
Number of Capital Letter(s) is <input type="text" id="upper_str" name="upper_str" size="3"/>
<br><br>
Number of Small Letter(s) is <input type="text" id="lower_str" name="lower_str" size="3"/>
</body>
</html>