Thread View: pl.comp.lang.javascript
2 messages
2 total messages
Started by ŁR
Tue, 12 Apr 2011 10:04
[jquery] generator hasła
Author: ŁR
Date: Tue, 12 Apr 2011 10:04
Date: Tue, 12 Apr 2011 10:04
35 lines
1986 bytes
1986 bytes
Witam,
próbuję ogarnąć jquery i jeden z pluginów do generowania haseł. I niby
wszystko ok ale nie potrafię wywołać funkcji.
Jest sobie taki kod:
$.extend({
password: function (length, special) {
var iteration = 0;
var password = "";
var randomNumber;
if(special == undefined){
var special = false;
}
while(iteration < length){
randomNumber = (Math.floor((Math.random() * 100)) % 94) + 33;
if(!special){
if ((randomNumber >=33) && (randomNumber <=47)) { continue; }
if ((randomNumber >=58) && (randomNumber <=64)) { continue; }
if ((randomNumber >=91) && (randomNumber <=96)) { continue; }
if ((randomNumber >=123) && (randomNumber <=126)) { continue; }
}
iteration++;
password += String.fromCharCode(randomNumber);
}
return password;
}
});
// How to use
$.password(8);
Niby napisane jest jak to wywołać, ale nie mam pojęcia w jaki sposób.
Chciałbym aby wygenerowane hasło pojawiało się w polu input. Bardzo
proszę o jakieś sugestie, bo siedzę i wertuję dokumentacje od jquery,
ale jeszcze widać pewne rzeczy do mnie nie docierają.
Re: [jquery] generator hasła
Author: aaaa
Date: Tue, 12 Apr 2011 21:54
Date: Tue, 12 Apr 2011 21:54
13 lines
1417 bytes
1417 bytes
> Niby napisane jest jak to wywołać, ale nie mam pojęcia w jaki sposób.
> Chciałbym aby wygenerowane hasło pojawiało się w polu input. Bardzo proszę
> o jakieś sugestie, bo siedzę i wertuję dokumentacje od jquery, ale jeszcze
> widać pewne rzeczy do mnie nie docierają.
<input type="text" id="krowa">
<script type="text/javascript">
$('#krowa').val( $.password(8) );
</script>
--
A
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads