aspdotnet-suresh offers articles and tutorials,csharp dot net, articles and tutorials,VB.NET Articles,Gridview articles,code examples of 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

Find Number of Vowels in a String in JavaScript | Count Vowels in String using JavaScript

Feb 27, 2013

Here I will explain how to find number of vowels in a string in JavaScript or get vowels count in string in JavaScript.

In previous posts I explained many articles relating to JavaScript,
JQuery. Now I will explain how to find number of vowels in a string in JavaScript.

To get number of vowels in string using JavaScript we need to write the code like as shown below

<title>find number of vowels in a string in JavaScript</title>
<script type="text/javascript">
function GetVowels() {
var str = document.getElementById('txtname').value;
var count = 0, total_vowels="";
for (var i = 0; i < str.length; i++) {
if (str.charAt(i).match(/[a-zA-Z]/) != null) {
// findVowels
if (str.charAt(i).match(/[aeiouAEIOU]/))
total_vowels = total_vowels + str.charAt(i);
document.getElementById('vowels').value = total_vowels;
document.getElementById('vcount').value = count;
<div >
<table border="1px" cellspacing="0" width="30%" style="background-color: #FF6600; color:White">
<tr><td colspan="2" align="center"><b>Get Vowels from String</b></td></tr>
<td>Enter Text :</td>
<td><input type='text' id='txtname' /></td>
<td>Vowels Count :</td>
<td><input type='text' readonly="readonly" id='vcount'/></td>
<td>Total Vowels :</td>
<td><input type='text' readonly="readonly" id='vowels' /></td>
<td><input type='button' value='Get Vowels Count' onclick="javascript:GetVowels();" /></td>
Live Demo

For live demo check below

Get Vowels from String
Enter Text :
Vowels Count :
Total Vowels :

If you enjoyed this post, please support the blog below. It's FREE!

Get the latest,, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email


Anonymous said...
This comment has been removed by a blog administrator.

what if you are to know the number of vowels in different input text like five(5) textbox

Give your Valuable Comments

Note: Only a member of this blog may post a comment.

© 2015 All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.