View Single Post
  #9 (permalink)  
Old November 24th, 2004, 07:24 AM
elisabeth elisabeth is offline
Authorized User
Points: 183, Level: 3
Points: 183, Level: 3 Points: 183, Level: 3 Points: 183, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2004
Location: , , .
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello Chris!!
I think I know why we are having problems. When I tried your script, I first used the tabulator on field1 and then the cursor went to field4. After that I focused on field1, entered a value and used the tab, it went to field2 and using the tab from field2 the cursor went to field1 again!!.
Now if you enter a value the first time in field1 it works fine.

Anyway, here is my code:

<html>
<head>
<title></title>

<script type="text/javascript">

function disableFields()
{
 document.forms[0].field2.disabled=false;
 document.forms[0].field3.disabled=false;
}

function initForm1(form)
{
 var f1=form.field1.value;
 if (!f1.match(/^(\s)*$/) )
 {
   form.field2.disabled=false;
   form.field3.disabled=false;
   setTimeout("document.forms." + form.name + ".field2.focus()", 1);
 }
 else
 {
   form.field2.disabled=true;
   form.field2.value="";
   form.field3.disabled=true;
   form.field3.value="";
 }
}
</script>
</head>
<body onLoad=disableFields()>

<form name="myForm">
Field1:
<input type=text name="field1" tabindex=3 onBlur="initForm1(this.form);"
<br>
Field2:
<input type=text name="field2" tabindex=4 >
<br>
Field3:
<input type=text name="field3" tabindex=5 >
<br>
Field4:
<input type=text name="field4" tabindex=6>
</form>
</body>
</html>


Reply With Quote