| Author |
onblur/onchange workaround needed...
|
Vijay S. Rathore
Ranch Hand
Joined: Oct 29, 2001
Posts: 449
|
|
Hi, 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. <html> <head> <title>onblur Test</title> <script> function checkWeight(curObj){ if(curObj.value > 10){ if(!confirm("The object is overwight. Are you sure you want to proceed...?")){ curObj.select(); curObj.focus(); } } } </script> </head> <body> <form> <p><input type="text" size="20" name="T1" value="23" onfocus="this.select();" onblur="checkWeight(this);"> <input type="text" size="20" name="T2" value="25" onfocus="this.select();" onblur="checkWeight(this);"> <input type="text" size="20" name="T3" value="27" onfocus="this.select();" onblur="checkWeight(this);"></p> </form> </body> </html>
|
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
author
Rancher
Joined: Nov 08, 2001
Posts: 15357
|
|
|
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.
|
 |
 |
|
|
subject: onblur/onchange workaround needed...
|
|
|