TheFilmGod Posted March 24, 2008 Share Posted March 24, 2008 How do I use javascript to count the number characters/lowercase/uppercase/numbers of the string "pass"? var pass = document.basic.password.value; $chars = # of characters $l_let = # of lower letters $u_let # of upper letters $num = # of numbers Quote Link to comment Share on other sites More sharing options...
rhodesa Posted March 24, 2008 Share Posted March 24, 2008 How bout this? <script> var pass = document.basic.password.value; var chars = pass.length; var l_let = pass.match(/[a-z]/g).length; var u_let = pass.match(/[A-Z]/g).length; var num = pass.match(/\d/g).length; alert( "# Chars: "+chars+"\n"+ "# Lower: "+l_let+"\n"+ "# Upper: "+u_let+"\n"+ "# Numbers: "+num ); </script> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.