DEV Community

Madhuban Khatri
Madhuban Khatri

Posted on

JavaScript Password Strength Detector

In this Project, I am Creating a Password Strength Detector which can detect Password Strength using JavaScript Code. Detector can change self background into White, Red, Orange and Lime

Code is Here:

Html Code

<input type='password' id='pwd' oninput='myfun()'/>
<div id='idigator'></div>
Enter fullscreen mode Exit fullscreen mode

JavaScript Code:

function myfun()
   var txt, indigator;
   txt = document.getElementById('pwd');
   indigator = document.getElementById('indigator');

   { = 'white';
   else if(txt.value.length<5)
   { = 'red';
   else if(txt.value.length<10)
   { = 'orange';
   { = 'lime';
Enter fullscreen mode Exit fullscreen mode

If u need full code then watch the video above.

Thank You.

Top comments (2)

_garybell profile image
Gary Bell

It's not so much a password strength detector as a length detector. Length is not equal to strength. there's not much different in strength between passwords 1111 and 11111.

The strength of a password should be based on the entropy, not just length. Use of numbers, symbols, and mixed-case letters should be encouraged, not just enforcing a mandatory length with no other considerations.

madhubankhatri profile image
Madhuban Khatri

I'll improve this code is a demo purpose.
Normally we set our A/C password and website says more characters in field to create a Strong Password.
So I create this. 'More characters, More strong password'.