<html> <head> <script> function demo1() { var str = document.getElementById("input1").value var alphaCount=0 var digitCount=0 var spCount=0 for (let i = 0; i < str.length; i++) { let ascii = str.charCodeAt(i) if( (ascii>=65 && ascii<=90) || (ascii>=97 && ascii<=122) ) { //document.write(str[i] + " - Alphabet <br>") alphaCount++ } else if (ascii>=48 && ascii<=57) { //document.write(str[i] + " - digit <br>") digitCount++ } else { // document.write(str[i] + " - special char <br>") spCount++ } } document.write(spCount + " - special char <br>") document.write(digitCount + " - digits <br>") document.write(alphaCount + " - alphabets char <br>") } </script> </head> <body> <input type= "text" id="input1" placeholder="enter data"/> <br><br> <input type="button" value="Go" onclick="demo1()" /><br> </body> </html>
Office no.- 401,Shekhar Central Building ,Palasiya, Pin-code:452001, Indore
contact@codebetter.in
+91 88230 75444, +91 99939 28766