• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

retain textbox focus

 
sriram viswanathan
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the best way to retain textbox focus when a validation fails?
Scenario: Txt1 and Txt2 are next to each other. Both are mandatory fields. When we write code in Txt1 onblur, it fires only after yielding focus to Txt2. This causes a problem because, when we do Txt1.focus from onblur, it fires the Txt2 onblur, which in turn requests focus, thus going into a deadlock situation.

To avoid this, had to go for a dirty flag as in the code snippet below.

Is there a better way? Are there any good events that will work in IE as well as Firefox?

Note: Also tried
return false
inside onblur. Dint work.



Thanks in advance,
Sriram
[ September 10, 2008: Message edited by: sriram viswanathan ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64715
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"sriram", please check your private messages for an important administrative matter.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic