Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> input - onfocus/onblur
SeaDog
post
Post #1





Grupa: Zarejestrowani
Postów: 42
Pomógł: 0
Dołączył: 15.11.2010

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


Witajcie, znalazłem w internecie poniższy kod:

  1. <input type='password' name='password' value='xxxxxxxxxx' onfocus=\"if(this.value == 'xxxxxxxxxx') {this.value=''}\" onblur=\"if(this.value == '') { this.value='xxxxxxxxxx'}\" class='topinput' />


Chciałbym go lekko zmienić, żeby zamiast "gwiazdek", wyświetlany był zwykły napis: hasło
ale żeby podczas wpisywania hasła, wpisywany tekst był za "gwiazdkami".

W jaki sposób można to osiągnąć?
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
kamil4u
post
Post #2





Grupa: Zarejestrowani
Postów: 2 350
Pomógł: 512
Dołączył: 4.01.2009
Skąd: Wrocław / Świdnica

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


Masz:
Kod
<input type='password' name='password' value='hasło' id="test">
<script>
var el = document.getElementById('test');
el.type = 'text';
el.onfocus = function(){
if(this.value == 'hasło'){
  this.type = 'password';
  this.value = '';
}
}

el.onblur = function(){
if(this.value == ''){
  this.type = 'text';
  this.value = 'hasło';
}
}
</script>
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: 15.10.2025 - 03:32