Output : Count the number of vowels in a give string using JavaScript
Count Vowels - ITVoyagers
Total number of vowels is -
JavaScript program to count the number of vowels in a give string
HTML code
<!DOCTYPE html><html><head><metacharset="utf-8"><title>Count Vowels - ITVoyagers</title></head><body><inputtype="text"name="val"id="inputvalue"value="itvoyagers.in"><buttonid="convert_button"onclick="countVowels()">Count</button><br><divid="outputdiv">
Total number of vowels is - <spanid="outputspan"></span></div><!-- itvoyagers.in --><script type="text/javascript"src="countvowels.js"></script></body></html>
Javascript code (countvowels.js)
var inputvalue =document.getElementById("inputvalue");
var outputspan =document.getElementById("outputspan");
//itvoyagers.infunction countVowels()
{
outputspan.innerHTML = inputvalue.value.replace(/[^aeiouAEIOU]/g, "").length;
}