Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

onblur/onchange workaround needed...

 
Vijay S. Rathore
Ranch Hand
Posts: 449
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic