473,396 Members | 1,804 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

focus problems

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
Jul 23 '05 #1
1 1800
On Tue, 02 Nov 2004 11:53:18 +0100, Jens Körte <jk******@gmx.de> wrote:
Hi NG!
Hello. :)
I encountered some strange behaviour when using focus()
The focus method isn't the problem.

[snip]
<script language=JavaScript>
(This won't affect the outcome, by the way.)

The language attribute is deprecated and has been for about six years! Use
the (required) type attribute, instead:

<script type="text/javascript">

[snip]
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.


In the first case, the value is edited, yes, but it hasn't actually
changed. The value of the control when focus was gained was the same as
when focus was lost. That is how "change" is determined, and why
validation should occur (primarily) when the form is submitted (both
server- and client-side).

[snip]

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Trev Hunter | last post by:
Hi Folks, Sorry if you have seen this post before - I've posted it before, but it seems to have gotten lost in Outlook limbo - it's visible on the web interface, but not in any news reader I've...
3
by: Robert Oschler | last post by:
I have a textarea element that I have created an onblur() handler for. In the onblur() handler, I check to make sure that they have saved the contents of the edit box, before leaving it. If...
17
by: Neil Ginsberg | last post by:
OK, this is a stupid thing, but I can't seem to get this to work. I have a form with a subform (in continuous form view). A combo box on the main form has code in the AfterUpdate event which adds a...
3
by: jab3 | last post by:
Hello. I"m new to this group, and to JavaScript in general, so please forgive me if I breach local etiquette. I'm trying to implement some client-side 'dynamic' validation on a form. I'm having...
3
by: ken | last post by:
Hi, I have two fields on a form. When I fill in Field1, I set focus to the other(Field2) and then expect the user to update it. On lostfocus of Field2, if Field1 is not null, I do a msgbox,...
5
by: Michel Posseth [MCP] | last post by:
Hello we have encountered the following problems with the date time picker control A : datetime picker control gives focus to last entered field when moving back and forward with focus how do...
3
by: jan.loucka | last post by:
Hi, I looked around for this specific problem but could not find any answer - there's few things in VB but still nothing exactly like this so I'd appreciate any help. We're writing C# WinForm...
2
by: ramdil | last post by:
Hi All I have a form with section and multiple pages(tab sections) in the section.Now i have added a button in the form which when clicked will open a form.Now my problem is that when i click the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.