JavaScript ব্যবহার করে password strength পরীক্ষা

আসসালামু আলাইকুম। আশা করি সবাই ভালো আছেন।

আজ কীভাবে JavaScript ব্যবহার করে password strength পরীক্ষা করতে হই সেটা দেখব।

<pre><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
            .strength0
            {
                width:250px;
                background:#cccccc;
            }

            .strength1
            {
                width:50px;
                background:#ff0000;
            }

            .strength2
            {
                width:100px;
                background:#ff5f5f;
            }

            .strength3
            {
                width:150px;
                background:#56e500;
            }

            .strength4
            {
                background:#4dcd00;
                width:200px;
            }

            .strength5
            {
                background:#399800;
                width:250px;
            }
        </style>
		<script type="text/javascript">

           function chkPasswordStrength(txtpass)
           {
               var desc = new Array();
               desc[0] = "Very Weak";
               desc[1] = "Weak";
               desc[2] = "Better";
               desc[3] = "Medium";
               desc[4] = "Strong";
               desc[5] = "Strongest";

               var score   = 0;

               //if txtpass bigger than 6 give 1 point
               if (txtpass.length > 6) score++;

               //if txtpass has both lower and uppercase characters give 1 point
               if ( ( txtpass.match(/[a-z]/) ) && ( txtpass.match(/[A-Z]/) ) ) score++;

               //if txtpass has at least one number give 1 point
               if (txtpass.match(/\d+/)) score++;

               //if txtpass has at least one special caracther give 1 point
               if ( txtpass.match(/.[!,@,#,$,%,^,&,*,?,_,~,-,(,)]/) ) score++;

               //if txtpass bigger than 12 give another 1 point
               if (txtpass.length > 12) score++;

               document.getElementById('strendth').innerHTML = desc[score];
               document.getElementById('strendth').className = "strength" + score;
           }

       </script>
</head>

<body>
<form method="post" action="">
	Password:-  <input id="txtpassword" name="txtpassword" onkeyup ="chkPasswordStrength(this.value)"
    					size="40" type="password" value="" />
        <span id="strendth"></span>
        <input type="submit" value="save" />
</form>
</body>
</html></pre>

টিউনস ভালো লাগলে আমার ব্লগ  থেকে ঘুরে আসুন।

Level 0

আমি tanvir007123। বিশ্বের সর্ববৃহৎ বিজ্ঞান ও প্রযুক্তির সৌশল নেটওয়ার্ক - টেকটিউনস এ আমি 13 বছর 1 মাস যাবৎ যুক্ত আছি। টেকটিউনস আমি এ পর্যন্ত 13 টি টিউন ও 3 টি টিউমেন্ট করেছি। টেকটিউনসে আমার 0 ফলোয়ার আছে এবং আমি টেকটিউনসে 0 টিউনারকে ফলো করি।


টিউনস


আরও টিউনস


টিউনারের আরও টিউনস