Txheeb xyuas Lo Lus zais Lub Zog nrog Javascript thiab Qhia Cov Lus

Txheeb xyuas Lo Lus zais Lub Zog nrog Javascript thiab Qhia Cov Lus

Kuv tau ua qee qhov kev tshawb fawb txog kev nrhiav qhov ua piv txwv zoo ntawm Kev Siv Tus password Password uas siv JavaScript thiab Kev Tawm Tsam Nrog Rau (Regex). Hauv daim ntawv thov ntawm kuv kev ua haujlwm, peb ua tus xa rov qab mus xyuas qhov password muaj zog thiab nws yooj yim heev rau peb cov neeg siv.

Regex yog dab tsi?

Kev qhia tsis tu ncua yog kab xwm ntawm cov cim uas txhais lub qauv tshawb. Feem ntau, cov qauv zoo li no tau siv los ntawm txoj hlua tshawb nrhiav cov txheej txheem rau nrhiav or nrhiav thiab hloov kev khiav hauj lwm ntawm cov hlua, lossis rau kev tawm tswv yim pom zoo. 

Kab lus no mas nws yuav tsis qhia koj cov kab lus uas koj niaj hnub siv. Tsuas yog paub tias kev muaj peev xwm los siv Kev Qhia Ntawv Tshwj Xeeb yuav yooj yim kiag li koj txoj kev loj hlob thaum koj tshawb rau cov qauv hauv cov ntawv. Nws tseem tseem ceeb kom nco ntsoov tias feem ntau cov lus txhim kho tau siv qhov kev qhia siv tsis tu ncua ... yog li tsis tau txheeb thiab tshawb cov kab ntawv ib kauj ruam zuj zus, Regex feem ntau muaj ntau nrawm dua rau cov neeg rau zaub mov thiab sab-sab.

Kuv tshawb hauv web kuj nce mentsis ua ntej kuv pom ib qho piv txwv ntawm qee Cov Ntawv Zoo Hais Qhia uas nrhiav rau kev sib xyaw ua ke ntev, cim, thiab cim. Howver, cov code tau me ntsis ntau dhau rau kuv saj thiab txiav rau .NET. Yog li Kuv ua kom yooj yim cov cai thiab muab tso rau hauv JavaScript. Qhov no ua rau nws lees paub qhov lo lus zais lub zog nyob rau hauv lub sijhawm tiag tiag ntawm tus neeg siv lub browser ua ntej tshaj tawm rov qab… thiab muab qee qhov kev xav rau cov neeg siv ntawm tus password lub zog.

Ntaus Ib Lo Lus Nug

Nrog txhua qhov sib zog ntawm cov keyboard, tus password tau soj ntsuam nrog cov kev qhia tas li thiab tom qab ntawv tawm tswv yim muab rau cov neeg siv nyob rau hauv ib ncua deb ntawm nws.




Ntaus Tus Password

Nov yog Txoj Cai

cov Kev Tawm Tsam Nrog Rau ua txoj haujlwm zoo heev ntawm qhov ntev ntawm txoj cai:

  • Ntau lub cim - Yog tias qhov ntev hauv qab 8 cim.
  • Tsis muaj zog - Yog tias qhov ntev tsawg dua 10 cim thiab tsis muaj kev sib txuam ntawm cov cim, lub kaus mom, ntawv nyeem.
  • Medium - Yog tias qhov ntev yog 10 cim lossis ntau dua thiab muaj kev sib txuam ntawm cov cim, lub kaus mom, ntawv nyeem.
  • muaj zog - Yog tias qhov ntev yog 14 cim lossis ntau dua thiab muaj kev sib txuam ntawm cov cim, lub kaus mom, ntawv nyeem.

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

Qhia Koj Cov Lus Nug Password

Nws yog qhov tseem ceeb uas koj tsis txhob cia li lees paub qhov kev tsim kho lo lus zais hauv koj Javascript. Qhov no yuav pab txhua tus neeg nrog browser kev txhim kho cov cuab yeej los dhau ntawm tsab ntawv thiab siv xijpeem lo lus zais uas lawv xav tau. Koj yuav tsum ib txwm siv kev siv ntawm lub server sab-kos los siv lub password kom zoo ua ntej khaws cia hauv koj lub platform.

32 Comments

  1. 1
  2. 2

    UA TSAUG! UA TSAUG! UA TSAUG! Kuv tau raug dag nyob ib ncig ntawm 2 lub lis piam nrog damn lo lus zais lub zog code los ntawm lwm lub vev xaib thiab rub kuv cov plaub hau tawm. Koj qhov luv heev, ua haujlwm ib yam li kuv xav tau thiab qhov zoo tshaj, yooj yim rau cov javascript novice los hloov kho! Kuv xav kom khaws lub zog kev txiav txim siab thiab tsis cia daim ntawv xa tawm los txhawm rau hloov tus neeg siv tus password tshwj tsis yog tias nws tau ntsib lub zog kuaj. Lwm tus neeg cov lej twb dhau los lossis tsis ua haujlwm zoo lossis lwm yam. Kuv hlub koj! XXXXX

  3. 4

    ua tsaug rau Vajtswv rau cov neeg uas tuaj yeem sau ib daim ntawm kev tsim nyog.
    Tau muaj kev paub ib yam li Janis.

    Qhov no ua haujlwm tawm ntawm lub thawv uas yog zoo meej rau cov neeg zoo li kuv uas tsis muaj lub code javascript!

  4. 5
  5. 6

    Nyob zoo, ua ntej ntawm txhua tus ua tsaug ntau rau koj kev siv zog, Kuv sim siv qhov no nrog Asp.net tab sis ho tsis ua haujlwm, Kuv tab tom siv

    siv tag nrho, thiab nws tsis ua haujlwm, cov tswv yim ?!

  6. 7

    Txog Nisreen: tus lej hauv lub thawv uas tsis pom ntawd yuav tsis ua haujlwm nrog kev txiav. Cov lus tsocai yog messed. Ua qauv qhia kev txuas tus lej tau zoo txawm tias.

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

    "P @ s $ w0rD" qhia tau tias nyob rau qhov muaj zog, txawm hais tias nws yuav tawg tau ncaj ncees nrog kev rov ua tus tswj…
    Yuav kom siv cov ntaub ntawv zoo li no ntawm kev daws teeb meem, kuv ntseeg tias nws yog ib qho tseem ceeb los ua ke cov txheej txheem no nrog kev kos rov qab.

  11. 12
  12. 13

    Ua tsaug rau qhov chaws me me no Kuv tam sim no siv tau los ntsuam xyuas kuv tus lej zais thaum kuv cov qhua tuaj saib lawv cov password,

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

    muaj neeg qhia rau, vim li cas nws thiaj li tsis ua haujlwm rau kuv ..

    Kuv tau theej txhua tus cai, thiab muab tshuaj txhuam rau notepad ++, tab sis nws tsis ua haujlwm txhua?
    thov koj pab kuv ..

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

    Hom kev ntsuas “lub zog tshawb xyuas” ua rau tib neeg taug txoj kev phom sij heev. Nws suav tus cwj pwm txawv ntau yam dhau ntawm kab ntawv ntev, ua rau nws ntsuas tau luv dua, cov lej sib txawv ntau dua li muaj zog ntev dua, tsis tshua muaj ntau tus password. Ntawd yog kev poob haujlwm uas yuav ua rau koj cov neeg siv teeb meem yog tias lawv tau ntsib qhov kev hem thawj txaus ntshai heev.

    • 25

      Kuv tsis pom zoo, Jordan! Qhov piv txwv tau muab coj los tso ua piv txwv ntawm tsab ntawv. Kuv qhov kev pom zoo rau cov tib neeg yog siv cov cuab yeej tswj hwm tus password los tsim cov lus tshaj lij rau ib tus xaib tshwj xeeb rau nws. Ua tsaug!

  24. 26
  25. 27
  26. 28

    Kuv yeej zoo siab qhov koj tau tshawb nrhiav no ntau zaus tab sis thaum kawg kuv tau txais koj tus ncej thiab kuv yeej amzed. UA TSAUG

  27. 29
  28. 31

    Kuv ua tsaug rau koj sib qhia! Tau tab tom nrhiav rau txoj kev ua kom muaj zog lo lus zais hauv peb lub vev xaib thiab qhov no ua haujlwm raws li qhov kuv xav tau. Ua tsaug ntau!

Yuav ua li cas koj xav hais tias?

Qhov Web site no siv Akismet los txo cov kev pabcuam. Kawm li cas koj cov ntaub ntawv tawm tswv yim tiav.