Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Regain focus after lostfocus

Status
Not open for further replies.

696796

Programmer
Aug 3, 2004
218
GB
I am running a validation script on lostfocus of a textfield, this works fine, however, if the user manually selects another field (i.e.the other field getsfocus) the validation script runs, if the field does not pass the validation it is set the focus again but THEN the selected other field still gets the focus????

E.g. what is currently happening:

user selects txtValidateMe
user enters value in txtValidateMe
user selects txtOtherField
txtValidateMe.lostFocus validation script runs
txtValidateMe fails validation
txtValidateMe gets focus
txtOtherField gets focus

How do i stop txtOtherField getting focus once txtValidateMe has failed validation??????

Ta
 
If the validation fails put
txtValidateMe.setfocus
If they try to go to another field it will keep failing and so keep returning to that field

Hope this helps
Hymn
 
As your validation code is in the LostFocus event procedure of txtValidateMe you have to set the focus to another control before setting the focus back to txtValidateMe, something like this:
If validation fails Then
txtOtherField.SetFocus
txtValidateMe.SetFocus
End If

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top