• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

retain textbox focus

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Sheriff
Posts: 67756
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"sriram", please check your private messages for an important administrative matter.
 
I'm just a poor boy, I need no sympathy, because I'm easy come, easy go, little high, little low, little ad
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic