Practical - 7
Practical - 7
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Vowel</title>
</head>
<body>
<form name="form1">
<h1>Enter the string whose vowel is to be counted</h1>
<input type="text" name="text1">
<input type="button" name="btn_checkvowel" value="Click to count"
onclick="count()">
</form>
<script type="text/javascript">
function count()
{
var i,ch,str,counter=0;
str=form1.text1.value;
for(i=0;i<str.length;i++)
{
ch=str.charAt(i);
if(ch=='A' || ch=='a' || ch=='e' || ch=='E' || ch=='i' || ch=='I' || ch=='o' || ch=='O' ||
ch=='u' || ch=='U')
counter++;
}
alert("Number of vowels in Entered String is:"+counter);
}
</script>
</body>
</html>
Output