Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Focus in Netscape Works But Not In IE

Status
Not open for further replies.

no1biscuit

Programmer
Oct 8, 2001
67
US
I have a text field that on the on click I validate the field. If the field is not correct, I alert the user and set the focus. Well in IE 5.5 and 6 it does not work. It sets the focus to the next field. In Netscape 4.0 and 4.76 it works great. What am I doing wrong. Here is a section of the code....

function Validate(broke, shot, formname)
{if (broke.value == "")
{alert("Please enter the broke amount!");
}
else if (broke.value < (shot/2))
{if (confirm(&quot;Only &quot; + broke.value
+ &quot;broke? Is this really correct?&quot;)==false)
{broke.focus();
broke.select();
}
}
else if (broke.value > shot)
{alert(&quot;You cannot break
more than you shot&quot;);
broke.focus();
broke.select();
}
Response.Write &quot;<tr><td><input type=textbox size=3 value='&quot; & Broke
& &quot;' maxlength=4 name=B&quot; &
TEventrs.Fields(0) & &quot;
onChange='Validate(this,&quot; & Shot & &quot;, document.EditScores)'></td></tr>&quot;
 
on what click? earm.. i meant onclick on what? .. you know what i mean.. could you post a piece of form here for us to see?

focusing the next field might happen if you call that function onchange.. Victor
 
I am sorry. It is already on the onchange event. I bolded the onchange. This is written in asp...
Thanks again for the help.
Thom

Response.Write &quot;<tr><td><input type=textbox size=3 value='&quot; & Broke
& &quot;' maxlength=4 name=B&quot; &
TEventrs.Fields(0) & &quot;
onChange='Validate(this,&quot; & Shot & &quot;, document.EditScores)'></td></tr>&quot;
 
onchange fires after change that user made

something like:

blur -> focus to the next element -> change

so, use onblur or onsubmit in your form tag Victor
 
Using the onblur does not allow the user to change the info in the box. I want the user to input a value. Once it is changed then I want to validate it. If it is not what I am looking for then pop up an alert and force the user to try again.
I don't want to use the onsubmit because, I want the user to know that they have made an error as soon as it concerns.

Thanks
Thom
 
>>Using the onblur does not allow the user to change the info in the box

no'p, don't think so.. i mean, it DOES allow to do that

onfocus=blur() won't allow to, but onblur=validate() would work properly.. i guess.. Victor
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top