Validate a Control in a Simple Way

Navigation:  How To... >

Validate a Control in a Simple Way

Previous pageReturn to chapter overviewNext page

The following steps have to be performed to create a validation setup for a control:

 

1.Place an Error Provider component on a form, e.g TNGHintErrorProvder (NGHintErrorProvder1), set up its properties as desired; Place a Validator component on a form, e.g. TNGRegExpValidator (NGRegExpValidator1);

2.Set up the properties of the validator component, e.g. set RegExp property of LMDRegExpValidator1 to '^[\d]+$' to allow values which represent non-negative integer numbers and ErrorMessage to 'The field %F should contain a non-negative integer number!' (where %F is a placeholder for the field name);

3.Set Provider property of LMDRegExpValidator1 to TLMDHintErrorProvder1;

4.Place a Validated Input Control on a form, e.g. TNGEdit (NGEdit1);

5.Set Validator property of LMDEdit1 to NGRegExpValidator1, ErrorMsgString property to 'Edit1'.

 

Now if the text in LMDEdit1 doesn't represent a non-negative integer number, a hint message will appear: 'The field Edit1 should contain a non-negative integer number!', if it does, the hint message will disappear.