Onani Mphamvu Zachinsinsi ndi JavaScript komanso Mawu Okhazikika

Onani Mphamvu Zachinsinsi ndi JavaScript komanso Mawu Okhazikika

Ndinkafufuza kuti ndipeze chitsanzo chabwino cha Chinsinsi cha Mphamvu Zachinsinsi chomwe chimagwiritsa ntchito JavaScript ndi Mawu Otsimikizika (Regex). Pakugwiritsa ntchito kwanga, timatumizanso kuti titsimikizire mphamvu ya mawu achinsinsi ndipo ndizovuta kwa ogwiritsa ntchito.

Regex ndi chiyani?

Mawu okhazikika ndi mndandanda wazinthu zomwe zimatanthauzira kafukufuku. Nthawi zambiri, zoterezi zimagwiritsidwa ntchito ndi njira zosakira zingwe za kupeza or pezani ndikusintha ntchito zingwe, kapena kutsimikizira kolowera. 

Nkhaniyi sikuyenera kukuphunzitsani mayankhulidwe wamba. Ingodziwa kuti kutha kugwiritsa ntchito Mawu Okhazikika kudzachepetsa kukula kwanu mukamasanthula zolemba. Ndikofunikanso kudziwa kuti zilankhulo zambiri zachitukuko zathandiza kuti anthu azigwiritsa ntchito mawu mofananira… m'malo mongofufuza ndi zingwe pang'onopang'ono, Regex imakhala yofulumira kwambiri pa seva ndi mbali ya kasitomala.

Ndinafufuza pa intaneti pang'ono ndisanapeze chitsanzo mwazinthu zina zazikulu zomwe zimayang'ana kuphatikiza kutalika, zilembo, ndi zizindikilo. Momwemo, codeyi inali yocheperako pang'ono pakukonda kwanga komanso yogwirizana ndi .NET. Chifukwa chake ndidachepetsa codeyo ndikuyiyika mu JavaScript. Izi zimapangitsa kutsimikizira mphamvu ya mawu achinsinsi munthawi yeniyeni pamsakatuli wa kasitomala musanatumize ... ndikupereka mayankho kwa wogwiritsa ntchito mawu achinsinsi.

Lembani A Achinsinsi

Pogwiritsa ntchito kiyibodi iliyonse, mawu achinsinsi amayesedwa motsutsana ndi mawu wamba ndiyeno mayankho amaperekedwa kwa wogwiritsa ntchito munthawi yake.




Lembani Chinsinsi

Nayi Code

The Mawu Otsimikizika Chitani ntchito yabwino kwambiri yochepetsera kutalika kwa code:

  • Zolemba zina - Ngati kutalika kuli pansi pa zilembo 8.
  • Ofooka - Ngati kutalika kwake kuli ochepera zilembo 10 ndipo kulibe kuphatikiza zizindikilo, zisoti, mawu.
  • sing'anga - Ngati utali uli ndi zilembo 10 kapena kupitilira apo ndipo uli ndi zisonyezo, zisoti, zolemba.
  • Strong - Ngati utali uli ndi zilembo 14 kapena kupitilira apo ndipo uli ndi zisonyezo, zisoti, mawu.

<script language="javascript">
    function passwordChanged() {
        var strength = document.getElementById('strength');
        var strongRegex = new RegExp("^(?=.{14,})(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*\\W).*$", "g");
        var mediumRegex = new RegExp("^(?=.{10,})(((?=.*[A-Z])(?=.*[a-z]))|((?=.*[A-Z])(?=.*[0-9]))|((?=.*[a-z])(?=.*[0-9]))).*$", "g");
        var enoughRegex = new RegExp("(?=.{8,}).*", "g");
        var pwd = document.getElementById("password");
        if (pwd.value.length == 0) {
            strength.innerHTML = 'Type Password';
        } else if (false == enoughRegex.test(pwd.value)) {
            strength.innerHTML = 'More Characters';
        } else if (strongRegex.test(pwd.value)) {
            strength.innerHTML = '<span style="color:green">Strong!</span>';
        } else if (mediumRegex.test(pwd.value)) {
            strength.innerHTML = '<span style="color:orange">Medium!</span>';
        } else {
            strength.innerHTML = '<span style="color:red">Weak!</span>';
        }
    }
</script>
<input name="password" id="password" type="text" size="15" maxlength="100" onkeyup="return passwordChanged();" />
<span id="strength">Type Password</span>

Kuumitsa Pempho Lanu Labwino

Ndikofunikira kuti musamangotsimikizira mapangidwe achinsinsi mu Javascript yanu. Izi zitha kuthandiza aliyense amene ali ndi zida zogwiritsa ntchito osatsegula kuti adutse pulogalamuyo ndikugwiritsa ntchito mawu achinsinsi omwe angafune. Muyenera kugwiritsa ntchito cheke cham'mbali nthawi zonse kuti mutsimikizire mphamvu ya mawu achinsinsi musanayisunge papulatifomu yanu.

34 Comments

  1. 1
  2. 2

    ZIKOMO! ZIKOMO! ZIKOMO! Ndakhala ndikupusitsa kwamasabata a 2 ndili ndi nambala yamphamvu yachinsinsi yochokera kumawebusayiti ena ndikutulutsa tsitsi langa. Yanu ndi yaifupi, imagwira ntchito monga momwe ndimafunira koposa zonse, zosavuta kwa novice wa javascript kuti asinthe! Ndinkafuna kutenga chigamulo cha mphamvu ndikulola kuti fomuyo isinthe kwenikweni mawu achinsinsi a ogwiritsa ntchito pokhapokha atakumana ndi mayeso. Ma code a anthu ena anali ovuta kwambiri kapena sanali kugwira bwino kapena china. Ndimakukondani! Kutali

  3. 4

    zikomo mulungu chifukwa cha anthu omwe amatha kulemba kachidindo moyenera.
    Zinali zofanana ndi za Janis.

    Izi zimagwira kunja kwa bokosilo lomwe ndi langwiro kwa anthu onga ine omwe sangalembe JavaScript!

  4. 5
  5. 6

    Wawa, choyamba ndikuthokoza kwambiri chifukwa cha kuyesetsa kwanu, ndayesera kugwiritsa ntchito izi ndi Asp.net koma sizinagwire ntchito, ndikugwiritsa ntchito

    m'malo mwa tag, ndipo sizinagwire ntchito, malingaliro aliwonse ?!

  6. 7

    Kwa Nisreen: malamulo omwe ali m'bokosilo samagwira ntchito ndi cut'n'paste. Mawu omwewo ndi osokonezeka. Khodi yolumikizira chiwonetsero ndiyabwino ngakhale.

  7. 8
  8. 9
  9. 10
  10. 11

    "P @ s $ w0rD" akuwonetsa mwamphamvu, ngakhale atagundidwa mwachangu ndi mawu otanthauzira mawu ...
    Kutumiza mawonekedwe oterewa pa akatswiri pantchito, ndikukhulupirira kuti ndikofunikira kuphatikiza algorithm iyi ndi cheke chomasulira.

  11. 12
  12. 13

    Zikomo chifukwa cha kakhodi kameneka nditha kuyigwiritsa ntchito poyesa mphamvu yanga yachinsinsi alendo anga akalembetsa mapasiwedi awo,

  13. 14
  14. 15
  15. 16
  16. 17
  17. 18
  18. 19

    wina anganene, chifukwa chake sizinagwire ntchito yanga ..

    ndinakopera nambala yonseyi ndikundiyika pa notepad ++, koma sizigwira ntchito konse?
    chonde ndithandizeni..

  19. 20
  20. 21
  21. 22
  22. 23
  23. 24

    Mtundu uwu "wowunika mphamvu" umatsogolera anthu panjira yowopsa kwambiri. Imayang'ana kusiyanasiyana kwamakalata kupitilira mawu achinsinsi, kuwapangitsa kuti azitha kufupikitsa, mapasiwedi osiyanasiyananso kukhala olimba kuposa mapasiwedi ataliatali, ocheperako. Ichi ndi chinyengo chomwe chidzagwetse ogwiritsa ntchito anu m'mavuto ngati angakumane ndi chiwopsezo chachikulu chobera.

    • 25

      Sindikutsutsana, Jordan! Chitsanzocho chidangotulutsidwa monga chitsanzo cha script. Lingaliro langa kwa anthu ndikugwiritsa ntchito chida choyang'anira mawu achinsinsi kuti apange mawu achinsinsi pa tsamba lililonse lomwe lili nalo. Zikomo!

  24. 26
  25. 27
  26. 28
  27. 29
  28. 31
  29. 33

    Ndiwewopulumutsa moyo! Ndinali kulumikiza zingwe kumanzere ndi pakati ndikuganiza kuti pali njira yabwinoko ndikupeza nambala yanu yogwiritsa ntchito Regex. Ndinatha kusangalala nawo patsamba langa ... Simudziwa kuti izi zathandiza bwanji. Zikomo kwambiri Douglas !!

Mukuganiza chiyani?

Tsambali likugwiritsa ntchito Akismet kuchepetsa spam. Phunzirani momwe deta yanu ikufotokozera.