function inputBlank(frm:TForm):boolean; var i: integer; begin result:=false; with frm do begin for i:=0 to ComponentCount-1 do begin if (Components[i] is TEdit)and(Components[i].Tag = 1) then if TEdit(Components[i]).Text = '' then result:=true; end; end; end;
Notice in the above functions are parameter "frm" of type "TForm". Fill in the name of the form where the fields will be validation for this parameter. For example, add the following script on the event "onClick" your submit button.
procedure TForm1.Button1Click (Sender: TObject); begin
if inputblank (self) then begin
ShowMessage ('There's still an empty field');
exit;
end;
ShowMessage ('Data is stored'); end;
In the example above, the parameter "self" is used for validation on the form itself.
No comments:
Post a Comment