Friday, August 18, 2017

Count number of Consonants in Real Time in JQuery

In this program it will ask the user to give a sentence and then our program will count the number of consonants in a given sentence by our user using JQuery in real time.  The code is very short and easy to understand and use.

I hope you will find my work useful and beneficial. If you have some questions about programming, about my work please send mu an email at jakerpomperada@gmail.comand jakerpomperada@yahoo.com. People here in the Philippines can contact me at  my mobile number 09173084360.

Thank you very much and Happy Programming.





Sample Program Output


Program Listing

<!DOCTYPE html>
<html>
    <head>
        <title>Count number of Consonants in Real Time in JQuery</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
 <style>
 body {
      font-family:arial;
               font-weight:bold;
  background-color:lightgreen;
               size:15;
    }
 
 </style>
        <script>
            $(function () {
                    $('#txtbox').keyup(function () {
                    var txtconsonants = $(this).val().replace(/[^bcdfghjklmnpqrstvwxyz]/gi,'').length;
                    $('#txtconsonants_ok').text(txtconsonants);
               });
            });
        </script>
    </head>
    <body>
   <br><br>
        <div style="padding-bottom: 25px;">Count number of Consonants in Real Time in JQuery</div>
        <div>
            Enter your text: <input style="padding: 7px;" maxlength="60" size="60" type="text" id="txtbox" required/>
           <br><br>
  <p>Number of consonants in the given string or sentence : <span id="txtconsonants_ok"></span></p>
        </div>
    </body>

</html>


No comments:

Post a Comment