- How to validate a control in a simple way?
1. | Place an error provider component on a form, e.g TLMDHintErrorProvder (TLMDHintErrorProvder1), set up its properties as desired; |
2. | Place a validator component on a form, e.g. TLMDRegExpValidator (LMDRegExpValidator1); |
3. | 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); |
4. | Set ErrorProvider property of LMDRegExpValidator1 to TLMDHintErrorProvder1; |
6. | Set Validator property of LMDEdit1 to LMDRegExpValidator1, 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.
|