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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TEdit - Need to do Validation / Double Entry before skip to next field

Status
Not open for further replies.

markemoss

Programmer
Mar 23, 2002
4
0
0
US
I need to be able to do Validation / Double Entry before I exit the TEdit Component.

What I want to do is let them finish typing in the value they want, then intercept the Tab to the next field, delete what they just entered and have them retype the data again and verify that it matches and then go to the next field.
 
Hook into the OnExit event and you'll be able to check the data.
With SetFocus method 'restore' focus to the unfinished edit control.

(Unchecked)

HTH
TonHu
 
You may also want to try a TMaskEdit if what they need to enter is always, for example, a 2 digit decimal or a 6 letter word...

"If it is stupid and it works then it isn't stupid"
 
1. Use 2 edit boxes
If you wish to check the key pressed, i.e validate entry when return / enter button is pressed then do the following:

Set the form's key preview on ( or true I can't remember)
Then in the edit1.keypress event type==>
{user types presses enter key after entering text}
if key = #13 then
edit2.setfocus;
Then set edit2.keypress event to read:
if key = #13 then {user presses enter key after typing text}
if Edit1.text = edit2.text then
begin
xyz {code for correct entry}
abc
showMessage('text matches');
end
else
begin
......{code for wrong entry}
showMessage('Wrong entry');
edit2.clear;
edit2.setfocus;
end;

The above code needs the form.key preview set for it to work.

Then you can check 1st edit box text value stored in the variable against the second entry.
Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top