Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Input[text] jak input[password]
topcio
post
Post #1





Grupa: Zarejestrowani
Postów: 140
Pomógł: 0
Dołączył: 14.01.2017

Ostrzeżenie: (0%)
-----


Hej.
Powiedzcie mi proszę czy to ma sens:
Celem skryptu jest aby w polu input text można było wpisywać hasło, tak jak w polu input[password], chodzi o to, że text nie jest nigdy zapamiętywany przez przeglądarki, a chcę osiągnąć taki efekt aby nie było widać co się wpisuje w pole text, ale można było przesłać jego zawartość do walidacji.

[JAVASCRIPT] pobierz, plaintext
  1. $(function() {
  2. $('#tb1').on("change paste keydown keyup", function(e) {
  3. if (e.which == 8) {
  4. var test = $('#txt').val();
  5. var newstring = test.substring(0, test.length - 1)
  6. $('#txt').val(newstring);
  7. }
  8.  
  9. var string = $('#txtCustName').val();
  10. var txtClone = $(this).val();
  11. $('#txtCustName').val(txtClone);
  12.  
  13. // $("#txt").val(text_stord);
  14. string = $('#txtCustName').val();
  15.  
  16. var i = -1,
  17. length = $('#txt').val().length;
  18.  
  19. for (i; i < length; i++) {
  20. string = string.replace(/./g, '*');
  21. $("#tb1").val(string);
  22. }
  23.  
  24. var j = -1,
  25. length2 = $('#txt').val().length;
  26. var test = $('#txt').val();
  27.  
  28. for (j; j < length2 + 1; j++) {
  29. test = test.replace(/\*/g, "");
  30. $('#txt').val(test);
  31. }
  32.  
  33. $("#txt").val(($("#txt").val()) + ($("#txtCustName").val().slice(-1)));
  34. if (($('#txt').val().length) > ($('#tb1').val().length)) {
  35. test = test.replace(/\*/g, "");
  36. $('#txt').val(test);
  37. }
  38. });
  39. });
  40.  
[JAVASCRIPT] pobierz, plaintext


działanie skryptu można zobaczyć na

http://jsfiddle.net/e9KFT/205/

Ten post edytował topcio 18.03.2018, 11:17:27
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 28.09.2025 - 12:54