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! Bendizibhanxa iiveki ezi-2 ngekhowudi yamandla egama eliyimfihlo evela kwezinye iiwebhusayithi kwaye nditsala iinwele zam ngaphandle. Eyakho imfutshane, isebenza kanye njengoko ndifuna kwaye okona kulungileyo kuko konke, kulula kwi-novice ye-javascript ukuyiguqula! Bendifuna ukubamba isigwebo samandla kwaye ndingavumeli iposti yefomu ukuba ihlaziye igama eliyimfihlo lomsebenzisi ngaphandle kokuba idibene novavanyo lwamandla. Ikhowudi yabanye abantu ibintsokothile kakhulu okanye ingasebenzi kakuhle okanye enye into. Ndiyakuthandana! XXXXX

  3. 4

    enkosi uthixo ngabantu abakwaziyo ukubhala ikhowudi ngokufanelekileyo.
    Unamava afanayo noJanis.

    Oku kusebenza kanye ngaphandle kwebhokisi elungele abantu abafana nam abangenako ikhowudi ye-javascript!

  4. 5
  5. 6

    Molo, okokuqala enkosi kakhulu ngemizamo yakho, ndizamile ukusebenzisa le Asp.net kodwa ayizange isebenze, ndisebenzisa

    endaweni yethegi, kwaye ayizange isebenze, naziphi na iingcebiso?!

  6. 7

    Ukuya eNisreen: ikhowudi ekwibhokisi ephawulweyo ayisebenzi nge cut'n'paste. Isicaphulo esinye simoshakele. Ikhowudi yekhonkco lokubonisa ilungile nangona kunjalo.

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

    "P@s$w0rD" ibonakalisa ngamandla, nangona iya kuqhekezwa ngokukhawuleza ngohlaselo lwesichazi-magama...
    Ukuhambisa into enjalo kwisisombululo sobungcali, ndiyakholwa ukuba kubalulekile ukudibanisa le algorithm kunye netshekhi yesichazimagama.

  11. 12
  12. 13

    Enkosi ngale khowudi incinci ngoku ndingayisebenzisa ukuvavanya amandla am ipasiwedi xa iindwendwe zam .zifaka amagama ayimfihlo,

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

    kukho umntu onokuthi, kutheni ingasebenzi kum..

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

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

    Olu hlobo "lokukhangela amandla" lukhokelela abantu kwindlela eyingozi kakhulu. Ixabisa iyantlukwano yabalinganiswa ngaphezu kobude bebinzana lokugqithisa, ikhokelela ekubeni ilinganise amafutshane, amagama agqithisiweyo ahlukeneyo anamandla kunexesha elide, lamagama agqithisiweyo ngaphantsi. Obo bubuxoki obuya kufaka abasebenzisi bakho engxakini ukuba bakhe bajongane nesoyikiso esinzulu sokugqekeza.

    • 25

      Andivumi, Jordan! Umzekelo ubekwe nje njengomzekelo weskripthi. Ingcebiso yam ebantwini kukusebenzisa isixhobo sokulawula igama lokugqitha ukwenza amagama okungena azimeleyo kuyo nayiphi na indawo eyohlukileyo kuyo. Enkosi!

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

    Ungumlondolozi ophilayo! Bendisahlulahlula iintambo ngasekhohlo nasekunene kwaye ndacinga ukuba kukho indlela engcono kwaye ndifumene ikhowudi yakho usebenzisa iRegex. Ndikwazile ukunkcunkca ngayo kwindawo yam…Awuyazi ukuba oku kuncede kangakanani. Enkosi kakhulu Douglas !!

Ingaba ucinga ntoni?

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