Let's take a look at how to use Knockout to implement password strength verification more simply. Please view the original code: Copy code The code is as follows: < body> <br>//CharMode function <br>function CharMode(iN) { <br>if (iN >=48&& iN <=57) / /Numbers<BR>return1; <BR>if (iN >=65&& iN <=90) //Capital letters<BR>return2; <BR>if (iN >=97&& iN <=122) // Lowercase <BR>return4; <BR>else <BR>return8; //Special characters <BR>} <BR>//bitTotal function <BR>function bitTotal(num) { <BR>modes =0; <BR>for (i =0; i <4; i ) { <BR>if (num &1) modes ; <BR>num >>>=1; <br>} <br>return modes; <br>} <br>//checkStrong function<br>function checkStrong(sPW) { <br>if (sPW.length <=4) <BR>return0; //Password is too short<BR>Modes =0; <BR>for (i =0; i < sPW.length; i ) { <BR>Modes |= CharMode(sPW.charCodeAt(i)); <BR>} <BR>return bitTotal(Modes); <BR>} <BR>//pwStrength function <BR>function pwStrength(pwd) { <BR>O_color ="#eeeeee"; <BR>L_color ="#FF0000"; <BR>M_color ="#FF9900"; <BR>H_color =" #33CC00"; <BR>if (pwd ==null|| pwd =='') { <BR>Lcolor = Mcolor = Hcolor = O_color; <BR>} else { <BR>S_level = checkStrong(pwd); <BR>switch (S_level) { <BR>case0: <BR>Lcolor = Mcolor = Hcolor = O_color; <BR>case1: <BR>Lcolor = L_color; <BR>Mcolor = Hcolor = O_color; <BR>break; <BR>case2: <BR>Lcolor = Mcolor = M_color; <BR>Hcolor = O_color; <BR>break; <BR>default: <BR>Lcolor = Mcolor = Hcolor = H_color; <BR>} <BR>document. getElementById("strength_L").style.background = Lcolor; <BR>document.getElementById("strength_M").style.background = Mcolor; <BR>document.getElementById("strength_H").style.background = Hcolor; <BR>return; <BR>} <BR>} Enter password: Password strength: height="23" style='display: inline'> Weak 中 strong