Hi I am trying to count the vowels of the input of the form in my HTML using javascript currently with no success.
Here is my HTML
<!doctype html>
<html>
<head>
<script src='p3-vowels.js'></script>
</head>
<body>
<form action="demo_form.asp">
Phrase: <input type="text" id = "input1" name="CountVowels" value="Put Phrase Here"><br>
<input type="button" id = "btn1" value="Check for Vowels">
</form>
</body>
</html>
and here is my javascript
function vow(form){
var a = form.CountVowels.value;
flag = 0;
for (var i = 0; i < a.length; i++){
switch (a[i]){
case 'a'
case 'e'
case 'i'
case 'o'
case 'u'
flag++;
break;
}
}
alert(flag);
}
function init(){
var button1 = document.getElementById("btn1")
button1.onclick = vow;
}
window.onload = init;