Jonga amandla ePhasiwedi ngeJavaScript kunye neeNkcazo eziQhelekileyo

Jonga amandla ePhasiwedi ngeJavaScript kunye neeNkcazo eziQhelekileyo

Ndenza uphando malunga nokufumana umzekelo olungileyo wokujonga amandla ePhasiwedi oyisebenzisayo JavaScript kwaye Iintetho eziQhelekileyo (Regex). Kwisicelo esisemsebenzini wam, senza umva ukubuyisela emuva ukuqinisekisa ubungqina begama eligqithisiweyo kwaye akulunganga kubasebenzisi bethu.

Yintoni iRegex?

Inkcazo eqhelekileyo kukulandelelana kwabalinganiswa abachaza ipatheni yokukhangela. Ngokwesiqhelo, iipateni ezinjalo zisetyenziswa ngumtya wokukhangela ubuchule kwi fumana or fumana kwaye ubeke endaweni yayo ukusebenza kwintambo, okanye ukungqinisisa igalelo. 

Eli nqaku ngokuqinisekileyo alikukufundisi amabinzana aqhelekileyo. Yazi nje ukuba ukubanakho ukusebenzisa iiNkcazo eziQhelekileyo kuya kulwenza lula ngakumbi uphuhliso lwakho njengoko ukhangela iipateni kwisicatshulwa. Kukwabalulekile ukuba uqaphele ukuba uninzi lweelwimi eziphuculweyo zilungiselele ukusetyenziswa kwesiqhelo rhoqo… endaweni yokuhluza kunye nokukhangela imitya inyathelo ngenyathelo, iRegex ihlala ikhawuleza kakhulu kumncedisi nakwicala labathengi.

Ndakhangela iwebhu kancinci ngaphambi kokuba ndifumane umzekelo kwezinye iiNtetho eziQhelekileyo eziJonga indibaniselwano yobude, abalinganiswa kunye neesimboli. Nangona kunjalo, ikhowudi yayigqithise incasa yam kwaye ilungiselelwe iNET. Ndiye ndenza lula ikhowudi ndayifaka kwiJavaScript. Oku kuyenza iqinisekise amandla epaswedi ngexesha lokwenyani kwisikhangeli somthengi ngaphambi kokuyithumela kwakhona… kwaye inike ingxelo kumsebenzisi kumandla wegama eligqithisiweyo.

Chwetheza igama eliyimfihlo

Ngesibetho ngasinye sekhibhodi, iphasiwedi iyavavanywa ngokuchasene nentetho yesiqhelo kwaye ingxelo inikezelwa kumsebenzisi kwisithuba esingaphantsi kwayo.




Chwetheza igama lokugqithisa

Nantsi iKhowudi

The Iintetho eziQhelekileyo yenza umsebenzi omnandi wokunciphisa ubude bekhowudi:

  • Abalinganiswa abaninzi - Ukuba ubude buphantsi koonobumba abasi-8.
  • buthathaka -Ukuba ubude bungaphantsi koonobumba abali-10 kwaye abuqulathanga indibaniselwano yeesimboli, iminqwazi, isicatshulwa.
  • phakathi -Ukuba ubude ngabalinganiswa abali-10 okanye nangaphezulu kwaye unokudityaniswa kweesimboli, iminqwazi, isicatshulwa.
  • U namandla - Ukuba ubude ngoonobumba abali-14 okanye nangaphezulu kwaye unokudityaniswa kweesimboli, iminqwazi, isicatshulwa.

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

Kubalulekile ukuba ungaqinisekisi ukwakhiwa kwephasiwedi ngaphakathi kweJavascript yakho. Oku kuyakwenza ukuba nabani na onezixhobo zokuphucula isikhangeli agqithise kwiskripthi kwaye asebenzise igama eligqithisiweyo abangathanda. KUFUNEKA usebenzise isheke esecaleni kwiseva ukuqinisekisa amandla epaswedi ngaphambi kokuyigcina kwiqonga lakho.

34 Comments

  1. 1
  2. 2

    ENKOSI! ENKOSI! ENKOSI! Ndiye ndazikhohlisa malunga neeveki ze-2 ngekhowudi yamandla ephaswedi evela kwezinye iiwebhusayithi kunye nokukhupha iinwele zam. Eyakho imfutshane, isebenza kanye ngendlela endifuna ngayo kwaye eyona ilungileyo, ilula kwi-Java novice onokuyiguqula! Ndifuna ukufaka isigwebo samandla kwaye ndingavumeli iposti yefom ukuba ihlaziye iphasiwedi yomsebenzisi ngaphandle kokuba idibene novavanyo lwamandla. Ikhowudi yabanye abantu yayintsonkothe ​​kakhulu okanye yayingasebenzi kakuhle okanye enye into. Ndiyakuthanda! IXXXX

  3. 4

    enkosi uthixo ngabantu abangabhala ikhowudi ngokufanelekileyo.
    Unamava afanayo nakaJanis.

    Oku kusebenza kanye ngaphandle kwebhokisi efanelekileyo kubantu abanjengam abangakwaziyo ikhowudi yejavascript!

  4. 5
  5. 6

    Molo, okokuqala enkosi kakhulu kwimizamo ye-ur, ndizamile ukuyisebenzisa le Asp.net kodwa ayisebenzi, ndiyayisebenzisa

    endaweni yethegi, kwaye ayisebenzi, naziphi na iingcebiso?!

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

    "P @ s $ w0rD" ibonisa ngamandla, nangona iyakuqhekeka ngokukhawuleza kuhlaselo lwesichazi magama ...
    Ukuhambisa inqaku elinjalo kwisisombululo sobungcali, ndiyakholelwa ukuba kubalulekile ukudibanisa le algorithm kunye nesichazi magama.

  11. 12
  12. 13

    Enkosi ngale khowudi incinci ngoku ndingayisebenzisa ukuvavanya amandla egama eligqithisiweyo xa iindwendwe zam zingenisa amagama azo,

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

    Ngaba umntu angaxela, kutheni ingasebenzi kum.

    ndikope yonke ikhowudi, kwaye uyincamathisele kwi-notepad ++, kodwa ayisebenzi kwaphela?
    Nceda undincede..

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

    Olu hlobo "lokujonga amandla" lukhokelela abantu ezantsi kwindlela eyingozi kakhulu. Ixabisa iyantlukwano lomlinganiswa ngaphezulu kwebinzana logqithiso, olukhokelela kumgangatho omfutshane, amagama agqithisiweyo ahlukeneyo omelele kunamaphasiwedi amade, awafaniyo. Obo bubuxoki obuya kufaka abasebenzisi bakho engxakini ukuba baya kuze bajongane nesoyikiso sokuqhekeza.

    • 25

      Andiphikisani, Jordan! Umzekelo wabekwa nje njengomzekelo weskripthi. Ingcebiso yam ebantwini kukusebenzisa isixhobo solawulo lwegama eligqithisiweyo ukwenza izivakalisi ezizimeleyo kuyo nayiphi na indawo eyahlukileyo kuyo. Enkosi!

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

    Ungumsindisi ophilayo! Ndidibanisa imitya esekhohlo ngasekunene nakwindawo kwaye ndicinga ukuba ikhona indlela ebhetele kwaye ndafumana ikhowudi yakho ndisebenzisa iRegex. Ndikwazile ukuntywila ngayo kwindawo yam ... awunalo nofifi lokuba kuncede kangakanani oku. Enkosi kakhulu uDouglas !!

Ingaba ucinga ntoni?

Le sayithi isebenzisa i-Akismet ukunciphisa ugaxekile. Funda indlela idatha yakho yokubhaliweyo isetyenziswe ngayo.