RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TField.IsValidChar Method

Indicates whether a particular character is valid for the field.

Pascal
function IsValidChar(InputChar: Char): Boolean; virtual;
C++
virtual __fastcall Boolean IsValidChar(Char InputChar);

Call IsValidChar to determine if the character specified by InputChar can appear in the text representation of the field's value. Many data-aware controls use IsValidChar to check characters entered by the user to determine if they are valid. IsValidChar returns true if InputChar can appear in the field. IsValidChar returns false if InputChar is not a valid character for the field type. 

The valid characters for a field object are given by the ValidChars property. By default, field objects accept all characters as valid. For each DataType that restricts the set of valid characters, the default valid characters are listed below:

Valid characters 
ftSmallint  
Digits 0 to 9, plus sign (+), and minus sign (-).  
ftWord  
Digits 0 to 9, plus sign (+), and minus sign (-)  
ftAutoInc  
Digits 0 to 9, plus sign (+), and minus sign (-)  
ftInteger  
Digits 0 to 9, plus sign (+), and minus sign (-)  
ftLargeInt  
Digits 0 to 9, plus sign (+), and minus sign (-)  
ftCurrency  
Digits 0 to 9, plus sign (+), minus sign (-), the letter E (E or e) and the decimal separator from the regional settings in the Windows control panel.  
ftFloat  
Digits 0 to 9, plus sign (+), minus sign (-), the letter E (E or e) and the decimal separator from the regional settings in the Windows control panel  
ftBCD  
Digits 0 to 9, plus sign (+), minus sign (-), and the decimal separator from the regional settings in the Windows control panel.  

Note: For some datatypes, such as ftGraphic, IsValidChar returns true for all characters although not every character is valid for the field. IsValidChar provides only a rough validation of input characters. More refined character-by-character validation can be provided by an edit mask. Also, the value for a field is validated as a whole when it is written to the database record.
 

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!