J
Jens Körte
Hi NG!
I encountered some strange behaviour when using focus()
I use a form with several input-fields. A user can enter stuff. After
entering I want to check the value, i.e. that a number is only a
number etc.
I therefore started editing a Javascript. For test purposes it only
popup a message and sets the focus. In fact this is what I want to do,
but the scipt isn't it doing right.
Here is the script:
<script language=JavaScript>
function check(wert)
{
switch (wert)
{
case "Firma":
if (document.Anmeldungsform.Firma.value == '')
{
alert("Bitte geben Sie Ihre Firma ein...");
document.Anmeldungsform.Firma.focus();
}
break;
case "Vorname":
if (document.Anmeldungsform.Vorname.value == '')
{
alert("Bitte geben Sie Ihren Vornamen ein...");
document.Anmeldungsform.Vorname.focus();
}
break;
case "Nachname":
if (document.Anmeldungsform.Nachname.value == '')
{
alert("Bitte geben Sie Ihren Nachnamen ein...");
document.Anmeldungsform.Nachname.focus();
}
break;
}
}
</script>
And now the HTML-Part
<form name="Anmeldungsform" method="POST" action="mailer.php">
<p>Firma:
<input type="text" name="Firma" onChange="check('Firma')">
<br>
Ansprechpartner:<br>
Vorname:
<input type="text" name="Vorname" onChange="check('Vorname')">
<br>
Nachname:
<input type="text" name="Nachname" onChange="check('Nachname')">
<br>
</form>
Ths thing that happen is, that after entering noting in field 1
nothing happens. Focus changes to field 2 and no popup is shown. This
happens to all of the fields.
When I enter a value and then deletes the value I encounter no changes
of the shown behaviour.
Only if I enter a value, move to the next field, go back and delete
the value and the force to go to the nect field I get a popup. After
closing the popup the focus remains on the next field, i.e. it doesn't
jump back to the field where the user have to make changes.
I tried this script mainly on Mozilla, but also on IE.
Please help me
Jens Körte
I encountered some strange behaviour when using focus()
I use a form with several input-fields. A user can enter stuff. After
entering I want to check the value, i.e. that a number is only a
number etc.
I therefore started editing a Javascript. For test purposes it only
popup a message and sets the focus. In fact this is what I want to do,
but the scipt isn't it doing right.
Here is the script:
<script language=JavaScript>
function check(wert)
{
switch (wert)
{
case "Firma":
if (document.Anmeldungsform.Firma.value == '')
{
alert("Bitte geben Sie Ihre Firma ein...");
document.Anmeldungsform.Firma.focus();
}
break;
case "Vorname":
if (document.Anmeldungsform.Vorname.value == '')
{
alert("Bitte geben Sie Ihren Vornamen ein...");
document.Anmeldungsform.Vorname.focus();
}
break;
case "Nachname":
if (document.Anmeldungsform.Nachname.value == '')
{
alert("Bitte geben Sie Ihren Nachnamen ein...");
document.Anmeldungsform.Nachname.focus();
}
break;
}
}
</script>
And now the HTML-Part
<form name="Anmeldungsform" method="POST" action="mailer.php">
<p>Firma:
<input type="text" name="Firma" onChange="check('Firma')">
<br>
Ansprechpartner:<br>
Vorname:
<input type="text" name="Vorname" onChange="check('Vorname')">
<br>
Nachname:
<input type="text" name="Nachname" onChange="check('Nachname')">
<br>
</form>
Ths thing that happen is, that after entering noting in field 1
nothing happens. Focus changes to field 2 and no popup is shown. This
happens to all of the fields.
When I enter a value and then deletes the value I encounter no changes
of the shown behaviour.
Only if I enter a value, move to the next field, go back and delete
the value and the force to go to the nect field I get a popup. After
closing the popup the focus remains on the next field, i.e. it doesn't
jump back to the field where the user have to make changes.
I tried this script mainly on Mozilla, but also on IE.
Please help me
Jens Körte