Bheka Amandla Ephasiwedi nge-JavaScript kanye Nezincazelo Ezijwayelekile

Bheka Amandla Ephasiwedi nge-JavaScript kanye Nezincazelo Ezijwayelekile

Bengenza ucwaningo ngokuthola isibonelo esihle sesihloli sePhasiwedi esisebenzisayo i-JavaScript futhi Izinkulumo ezijwayelekile (Regex). Kuhlelo lokusebenza emsebenzini wami, senza okuthunyelwe emuva ukuqinisekisa amandla wephasiwedi futhi akukuhle neze kubasebenzisi bethu.

Yini i-Regex?

Isisho esijwayelekile ukulandelana kwezinhlamvu ezichaza iphethini yokusesha. Imvamisa, amaphethini anjalo asetshenziswa ngama-algorithm we-string search thola or thola bese ushintsha ukusebenza ngezintambo, noma ukuqinisekiswa kokufaka. 

Lo mbhalo nakanjani akufanele ukufundise izinkulumo ezijwayelekile. Yazi nje ukuthi amandla wokusebenzisa Izinkulumo Ezijwayelekile azokwenza lula ukukhula kwakho njengoba usesha amaphethini embhalweni. Kubalulekile futhi ukuqaphela ukuthi izilimi eziningi zentuthuko zithuthukise ukusetshenziswa kwezichasiso ezijwayelekile… ngakho-ke kunokuba zihlukanise futhi zicwaninge izintambo igxathu negxathu, iRegex imvamisa ishesha kakhulu kuzo zombili iseva nohlangothi lwamakhasimende.

Ngiseshe iwebhu kancane ngaphambi kokuthola isibonelo kwezinye izisho ezinhle ezijwayelekile ezifuna inhlanganisela yobude, izinhlamvu, nezimpawu. I-Howver, ikhodi yayiqine ngokweqile ukunambitheka kwami ​​futhi yenzelwe i-.NET. Ngakho-ke ngenza lula ikhodi ngayifaka kuJavaScript. Lokhu kuyenza iqinisekise amandla ephasiwedi ngesikhathi sangempela kusiphequluli seklayenti ngaphambi kokuyithumela futhi… futhi inikeze impendulo kumsebenzisi ngamandla wephasiwedi.

Thayipha iphasiwedi

Ngokushaywa ngakunye kwekhibhodi, iphasiwedi iyahlolwa ngokuqhathaniswa nenkulumo ejwayelekile bese impendulo inikezwa umsebenzisi esikhathini esingaphansi kwayo.




Thayipha iphasiwedi

Nayi ikhodi

The Izinkulumo ezijwayelekile yenza umsebenzi omuhle wokunciphisa ubude bekhodi:

  • Izinhlamvu eziningi - Uma ubude bungaphansi kwezinhlamvu eziyi-8.
  • ebuthakathaka - Uma ubude bungaphansi kwezinhlamvu eziyi-10 futhi bungaqukethe inhlanganisela yezimpawu, amakepisi, umbhalo.
  • Medium - Uma ubude buyizinhlamvu eziyi-10 noma ngaphezulu futhi bunenhlanganisela yezimpawu, amakepisi, umbhalo.
  • Strong - Uma ubude buyizinhlamvu eziyi-14 noma ngaphezulu futhi bunenhlanganisela yezimpawu, amakepisi, umbhalo.

<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>

Ukuqinisa Isicelo Sakho Sokungena

Kubalulekile ukuthi ungaqinisekisi ukwakhiwa kwephasiwedi ngaphakathi kweJavascript yakho. Lokhu kuzokwenza noma ngubani onamathuluzi wokuthuthukisa isiphequluli ukuthi adlule iskripthi futhi asebenzise noma iyiphi iphasiwedi angathanda. Kufanele NJALO usebenzise isheke-side isheke ukuqinisekisa amandla wephasiwedi ngaphambi kokuligcina kungxenyekazi yakho.

34 Amazwana

  1. 1
  2. 2

    NGIYABONGA! NGIYABONGA! NGIYABONGA! Bengilokhu ngikhohlisa amasonto ama-2 ngekhodi lamandla wephasiwedi elilahlekile kusuka kwamanye amawebhusayithi futhi ngikhipha izinwele zami. Okwakho kufushane, kusebenza ngendlela engifuna ngayo futhi okuhle kunakho konke, kulula ukuthi imfundamakhwela ye-JavaScript ikuguqule! Bengifuna ukuthatha isinqumo somandla futhi ngingavumeli okuthunyelwe kwefomu ukuthi kuvuselele empeleni iphasiwedi yomsebenzisi ngaphandle kokuthi kuhlangabezane nokuhlolwa kwamandla. Ikhodi yabanye abantu yayiyinkimbinkimbi kakhulu noma yayingasebenzi kahle noma enye into. Ngiyakuthanda! I-XXXXX

  3. 4

    bonga unkulunkulu ngabantu abakwazi ukubhala ucezu lwekhodi kahle kahle.
    Wayenolwazi olufana nolukaJanis.

    Lokhu kusebenza ngaphandle kwebhokisi okulungele abantu abanjengami abangafuni ikhodi ye-JavaScript!

  4. 5
  5. 6

    Sawubona, okokuqala ngiyabonga kakhulu ngemizamo ye-ur, ngizamile ukusebenzisa lokhu ngeAsp.net kepha angisebenzi, ngisebenzisa

    esikhundleni sethegi, futhi ayisebenzi, noma iziphi iziphakamiso?!

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

    “I-P @ s $ w0rD” ikhombisa ngamandla, yize izonqamphuka ngokushesha okukhulu ngokuhlaselwa kwesichazamazwi…
    Ukufaka isici esinjalo kusisombululo se-professionnal, ngikholwa ukuthi kubalulekile ukuhlanganisa le algorithm nesheke lesichazamazwi.

  11. 12
  12. 13

    Ngiyabonga ngale khodi encane manje sengingayisebenzisa ukuhlola amandla wami wephasiwedi lapho izivakashi zami zingena ngamaphasiwedi wazo,

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

    kukhona umuntu ongasho, ukuthi kungani kungasebenzanga okwami ​​..

    Ngikopishe yonke ikhodi, bese ngiyinamathisela ku-notepad ++, kepha ayisebenzi nhlobo?
    Ngicela ungisize..

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

    Lolu hlobo "lokuhlola amandla" luholela abantu phansi endleleni eyingozi kakhulu. Ikwazisa ukwehluka kwezinhlamvu ngobude bomushwana wokungena, okuyiholela ekulinganiseni amaphasiwedi amafushane, ahlukahlukene kakhulu kunamandla kunamaphasiwedi amade, angafani kakhulu. Lokho ngamanga okuzofaka abasebenzisi bakho enkingeni uma kungenzeka babhekane nosongo olunzima lokugenca.

    • 25

      Angiphikisi, Jordan! Isibonelo simiswe nje njengesibonelo sombhalo. Isincomo sami kubantu ukusebenzisa ithuluzi lokuphatha iphasiwedi ukudala imishwana yokungena ezimele yanoma isiphi isayithi elihlukile kulo. Ngiyabonga!

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

    Ungumsindisi obukhoma! Bengicubungula izintambo kwesobunxele nesikhungo futhi ngicabanga ukuthi kunendlela engcono ngathola ucezu lwakho lwekhodi ngisebenzisa iRegex. Ngikwazile ukuxoxa ngayo ngesiza sami… Awazi ukuthi lokhu kusize kangakanani. Ngiyabonga kakhulu uDouglas !!

UCABANGANI?

Le sayithi isebenzisa i-Akismet ukunciphisa ugaxekile. Funda ukuthi idatha yakho yokuphawula isetshenziswa kanjani.