473,466 Members | 1,554 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

focus on a input field


I've written the following function who works great in IE

function OnlyCharacter(tekst)
{
if (tekst.length == 1)
{
if (tekst >= "A" && tekst <="Z")
{return true}
}
window.alert ("Only uppercase");
form1.Sectie.focus();
}
But in Netscape or Mozilla I can't bring back the focus on the field
(Sectie) when the input is not correct

I've tried the following :
1) var box;
box = document.forms[0].elements[1];
box.focus()
2)document.getElementById("Sectie").focus();
3) document.form1.Sectie.focus()

but nothing seems to work.

How must I do that in Netscape and/or Mozilla ?
Jul 20 '05 #1
3 2006
"leiko" <dd***@pandora.be> wrote in message
news:4g********************@phobos.telenet-ops.be...

I've written the following function who works great in IE

function OnlyCharacter(tekst)
{
if (tekst.length == 1)
{
if (tekst >= "A" && tekst <="Z")
{return true}
}
window.alert ("Only uppercase");
form1.Sectie.focus();
}
But in Netscape or Mozilla I can't bring back the focus on the field
(Sectie) when the input is not correct

I've tried the following :
1) var box;
box = document.forms[0].elements[1];
box.focus()
2)document.getElementById("Sectie").focus();
3) document.form1.Sectie.focus()

but nothing seems to work.

How must I do that in Netscape and/or Mozilla ?


Below I added "document." in front of your "form1." references.

Also, I added the following lines:

document.form1.Sectie.select();
return false;
I tried the following and had no problem on NS 6.2.2:

<html>
<head>
<title>AZ.htm</title>
<script type="text/javascript">
function OnlyCharacter(tekst)
{
if (tekst.length == 1)
{
if (tekst >= "A" && tekst <="Z")
{return true}
}
window.alert ("Only uppercase");
document.form1.Sectie.focus();
document.form1.Sectie.select();
return false;
}
</script>
</head>
<body>
<form name="form1" onsubmit="return OnlyCharacter(form1.Sectie.value)">
<input type="text" size="1" maxlength="1" name="Sectie">
<input type="submit" value="Submit">
</form>
</body>
</html>

Jul 20 '05 #2
What you have written works when you submit your form.

But I've tried with the 'OnBlur' event and that doesn't work.
<input name="Sectie" type="text" id="Sectie" size="4" maxlength="1" value
="<?php echo $Sectie; ?>"
onBlur="return OnlyCharacter(form1.Sectie.value)">

P.S. I use NN 7.1

How can I solve this problem ?


"leiko" <dd***@pandora.be> schreef in bericht
news:4g********************@phobos.telenet-ops.be...

I've written the following function who works great in IE

function OnlyCharacter(tekst)
{
if (tekst.length == 1)
{
if (tekst >= "A" && tekst <="Z")
{return true}
}
window.alert ("Only uppercase");
form1.Sectie.focus();
}
But in Netscape or Mozilla I can't bring back the focus on the field
(Sectie) when the input is not correct

I've tried the following :
1) var box;
box = document.forms[0].elements[1];
box.focus()
2)document.getElementById("Sectie").focus();
3) document.form1.Sectie.focus()

but nothing seems to work.

How must I do that in Netscape and/or Mozilla ?

Jul 20 '05 #3
"leiko" <dd***@pandora.be> wrote in message
news:da********************@phobos.telenet-ops.be...
What you have written works when you submit your form.

But I've tried with the 'OnBlur' event and that doesn't work.
<input name="Sectie" type="text" id="Sectie" size="4" maxlength="1" value
="<?php echo $Sectie; ?>"
onBlur="return OnlyCharacter(form1.Sectie.value)">

P.S. I use NN 7.1

How can I solve this problem ?

I can't find a solution either.

Obviously, testing a field by "onblur=" or "onchange=" is problematic (on
NS).

I usually validate all fields at once via "onsubmit="...
Jul 20 '05 #4

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

Similar topics

2
by: fish | last post by:
Hi, I have an HTML page with a FORM and some input fields. On the fields I wish to do validation as the punters change the field values. If they get it wrong, then I tell them and then wish...
1
by: Robert Dickow | last post by:
Here's an interesting problem: When Netscape Nav plays an embedded sound, the current window will lose focus. Specifically, a user may be typing into a text input field, but an embedded sound in...
10
by: CES | last post by:
All, I'm having a problem returning focus back to an input field in Netscape. The code works in IE and Opera but not in netscape6+. Basically I have a function that is called upon...
6
by: Csaba | last post by:
I'd like to have the cursor in the login form's username input text field when users load the login page. It works fine with the following implementation: <body...
3
by: Dai Ba Wong | last post by:
Hi: Currently I am having a problem with my webpage. My page consist of two frames, one consist of input text field and the other contains link for different pop-up windows. The problem...
1
by: Jens Körte | last post by:
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...
3
by: VA | last post by:
t=document.getElementById('mytable') is a HTML table with some input fields in its cells Why doesnt t.getElementsByTagName('tr').firstChild.focus; put the focus on that text field? It...
4
by: planb | last post by:
Hi, I'd like to have a rollover like effect when a input field has the focus, any idea of how to do this with just CSS (easy enough with javascript)? What I'm thinking of is having a tips box...
1
by: Will_uk | last post by:
I am trying to return focus to a form input field. If i use <form>.<field>.focus() the focus returns to the field but if the field already contains a value it selects it (blacks it out). Is it...
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:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.