Check no.of vowels in javascript and html


<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>


<script language="javascript" type="text/javascript">
    function check()
    {
        var str =document.getElementById("textboxing").value;
        var chr = ""
        var nVowels = 0
        //Counting all the vowels except y.
        for (pos = 0; pos < str.length; pos++)
        {
            chr = str.charAt(pos);
            if (chr == "a" || chr == "e" || chr == "i" || chr == "o" || chr == "u" ||
                chr == "A" || chr == "E" || chr == "I" || chr == "O" || chr == "U")
                nVowels++;
        }
            alert("There were " + nVowels + " vowels.");
    }
    </script>
</head>

<body>

<input type="text" id="textboxing" />
    <input type="button" name="submit" value="check vowels" onclick="check()" />
</body>
</html>

Tags : vowels in html, javascript

Comments

Popular posts from this blog

Create Desktop Application with PHP

Insert pandas dataframe into Mongodb

Python desktop application