• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

question on changing focus

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have 2 textboxes and one checkbox. When I click on the checkbox, I want to do some validation and then put the focus on textbox 1 if the validation fails. I am not clear on how to change the focus back to the textbox 1.
Any help will be appreciated.
Thanks.
 
Ranch Hand
Posts: 228
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
use javascript form onLoad method to see if there is any error to make the focus for the form to the check box. that will work.
 
Nandu Raghu
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your response, Sandy.
I am still not clean how the onLoad handler would help me in this case. Can you please explain a little more.
Thanks.
 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is basically a JavaScript problem.
Right after your validation, probably in the OnChange() method of your checkbox, you could add javascript similar to this :
<...>
document.forms["form_name_here"].elements["textbox1_name_here"].focus();
<...>
Then textbox1 should get the focus...
 
Nandu Raghu
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you FrancK.
It worked !!
[ November 27, 2003: Message edited by: Nandu Raghu ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic