File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes onblur/onchange workaround needed... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "onblur/onchange workaround needed..." Watch "onblur/onchange workaround needed..." New topic

onblur/onchange workaround needed...

Vijay S. Rathore
Ranch Hand

Joined: Oct 29, 2001
Posts: 449
I have a series of text boxes and I have to warn the users about the value of these boxes with an confirm. Based on the selection from the warning I have to put focus back to the selected box.
When the page loads, the boxex can have values, not satisfying the condition.
Well onchange event somehow dosen't put the focus back on my field if I select cancel from my confirm box.
When I use onblur event it puts my screen into an infinite loop till ok is pressed.

Here is the sample of code that I am trying to explain. Does anyone know a workaround or any other way of doing the same.
<title>onblur Test</title>
function checkWeight(curObj){
if(curObj.value > 10){
if(!confirm("The object is overwight. Are you sure you want to proceed...?")){;
<p><input type="text" size="20" name="T1" value="23" onfocus=";" onblur="checkWeight(this);">
<input type="text" size="20" name="T2" value="25" onfocus=";" onblur="checkWeight(this);">
<input type="text" size="20" name="T3" value="27" onfocus=";" onblur="checkWeight(this);"></p>

SCJP, SCJD, SCWCD1.4, IBM486, IBM484, IBM 483, IBM 287, IBM141, IBM Certified Enterprise Developer - WebSphere Studio, V5.0
Author of IBM 287 Simulator Exam
Eric Pascarello

Joined: Nov 08, 2001
Posts: 15385
if you are forcing people to place the right string into the field then why are you using a confirm? You can use an alert instead.
I agree. Here's the link:
subject: onblur/onchange workaround needed...
It's not a secret anymore!