The script I'm using is like the following one. It has to work in IE. Other
browsers are not important for now, because it's meant as a field check for
a business application.
When you use the buttons to set focus to the appropriate field the function
used to setfocus works perfectly.
When the NotEmpty function is triggered by leaving the input field the focus
stays on the next selected field.
When you want to see this code working visit :
http://home.zonnet.nl/janwouter/script/focus.html
<html>
<head>
<script lang=javascript>
function NotEmpty(veld)
{
TestOk="N";
invoer=veld.value.toString();
for(var i=0;i<invoer.length;i++)
{
var teken =invoer.charAt(i);
if (teken != ' ')
{
TestOk="J";
i=invoer.length;
}
}
if (TestOk=="N")
{
/* alert('Veld mag niet leeg zijn');*/
veld.value="Field may not be empty !!";
focusonfield(veld);
}
} /*einde functie NotEmpty*/
function focusonfield(field)
{
if (field.name=="inp1")
{document.form1.inp1.focus()}
if (field.name=="inp2")
{document.form1.inp2.focus()}
if (field.name=="inp3")
{document.form1.inp3.focus()}
}
</script>
</head>
<body>
<form name ="form1">
<input name="inp1" value="veld1" onchange="NotEmpty(this)";/>
<input name="inp2" value="veld2" onchange="NotEmpty(this)";/>
<input name="inp3" value="veld3" onchange="NotEmpty(this)";/>
<br/>
<button name="but1" onclick="focusonfield(form1.inp1)">veld1</button>
<button name="but2" onclick="focusonfield(form1.inp2)">veld2</button>
<button name="but3" onclick="focusonfield(form1.inp3)">veld3</button>
</form>
</body>
"Stuart Palmer" <tr**********@youcant.com> schreef in bericht
news:2j*************@uni-berlin.de...
Can you supply your full code? (JS and forms html), what browsers are you
using too?
Stu