You are not logged in.

wcf.regNote.message

Spy

Trainee

  • "Spy" started this thread

Posts: 127

Occupation: Feriengammler

  • Send private message

1

Monday, June 25th 2007, 7:38pm

Javascript und IE - <input> Feld + onblur und onfocus

Hallo,

der Firefox macht das folgende ohne Probleme.
Reinklicken in PW Feld und der Text "Password" verschwindet und macht das Feld zu type 'password', ebenso funktioniert das onblur event.
Nur der IE macht den ersten teil und zwar er ändert nur die value werte aber nicht den type.

Source code

1
2
3
4
5
<td class=\"mnu_login2_td\">
<input class=\"mnu_login2\" name=\"txtPw\" size=\"12\" type=\"text\" value=\"Password\" 
onfocus=\"if (document.login.txtPw.value == 'Password') { document.login.txtPw.value = ''; document.login.txtPw.type = 'password'; }\" 
onblur=\"if (document.login.txtPw.value == '') { document.login.txtPw.value= 'Password';  document.login.txtPw.type = 'text';}\">
</td>


Wegen dem Design muss Password im Input stehen da der User kein "Label" für die Erklärung des Felds hat. Und einfache ****** in das PW Feld von vornerein könnte den User evtl. irretieren.
Hat einer eine Idee welche Eigenschaft der IE unterstützt anstatt type ?!

Tschaui
Die Welt ist irgendwie total Buggy programmiert X(

Noisy

Trainee

Posts: 65

Location: Frankfurt

  • Send private message

2

Tuesday, June 26th 2007, 12:05am

Source code

1
<input name="password" value="Pass" onfocus="if(this.value=='Pass') this.value=''" onblur="if(this.value=='')this.value='Pass'" type="password" />


Ist es das was du suchst? Funzt in alle Browsern ;)

Spy

Trainee

  • "Spy" started this thread

Posts: 127

Occupation: Feriengammler

  • Send private message

3

Tuesday, June 26th 2007, 6:24pm

Hallo,

hmm... nein da ist der type ja schon mit im Inputfeld festgelegt...
der muss erst type="password" setzen, wenn reingeklickt wurde
Aber vielleicht kann der IE keine zwei Anweisungen hinternander ausführen, wenn die auf einer Zeile stehen...
------------

Also daran liegt es auch nicht, der IE versteht das auch nicht in einem sauberen <script></script>. Und Firefox versteht es wiedermal...

------------

hmm.. in meiner reinen Freude das es Firefox so macht wie ich es will hab ich ganz und gar übersehen das type nur read-only ist. Da stell ich mir nun die Frage ob da mein Firefox ne macke hat und mich es beunruhigen sollte oder ob der IE lieber ebenso nachlässig sein sollte...
Dann muss ich wohl mit zwei <input> Feldern arbeiten ;(

-----------

hihi
Nach bischen Überlegung und probieren hab ich nun endlich ne Lösung für IE,Opera sowie für Firefox und Mozilla.

Source code

1
2
<input class=\"mnu_login2\" name=\"txtPw\" size=\"12\" type=\"text\" value=\"Password\" onfocus=\"password('txt1_in')\" onblur=\"password('txt1_out')\">
<input class=\"mnu_login2\" style=\"display:none;\" name=\"txtPw2\" size=\"12\" type=\"password\" onfocus=\"password('txt2_in')\" onblur=\"password('txt2_out')\" value=\"\">


Firefox Version:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
  function password(typ)
  {
     if (typ=='txt1_in')
    {
      if (document.login.txtPw.value == 'Password')
      {
        document.login.txtPw.value='';
        document.login.txtPw.type='password';
      }
    }
    if (typ=='txt1_out')
    {
      if (document.login.txtPw.value=='' && document.login.txtPw.type=='password')
      {
        document.login.txtPw.value='Password';
        document.login.txtPw.type='text';
      }
    }
  }


IE Version:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
 function password(typ)
  {
    if (typ=='txt1_in')
    {
    	document.login.txtPw.style.display='none';
      document.login.txtPw2.style.display='inline';
    }
    if (typ=='txt2_out')
    {
      if (document.login.txtPw2.value == '')
      {
      	document.login.txtPw.style.display='inline';
      	document.login.txtPw2.style.display='none';
      }
    }
  }


Da das ganze ne PHP Seite ist, war es auch kein Problem die Browser abzufragen.
Die Welt ist irgendwie total Buggy programmiert X(

This post has been edited 3 times, last edit by "Spy" (Jun 27th 2007, 2:03pm)


wcf.user.socialbookmarks.titel