View Single Post
 
Old 08-09-2018, 12:43 PM
rojam rojam is offline
Senior Member
 
Join Date: Jun 2015
Posts: 191
Default

Here is an implementation of the verhoeff algorithm in Delphi.

You could call this function from the Edit's OnExit method, like so:
Code:
procedure TForm1.Edit1OnExit(Sender: TObject);
begin
  if trim(Edit1.Text) <> '' then
    if ValidVerhoeff(Edit1.Text) then
    begin
      //a valid number was entered
    end
    else
      Edit1.SetFocus;//reset focus back to the edit control
   end;
end;
since you can't enforce that Edit1 has any value in OnExit, you'll also need to add code to the Save (to a database / file or what ever you use to save the information) to ensure that the edit control has a value.
Reply With Quote