How to validate the special characters
-
Hi all, In Dialog based application user has to enter the file name to continue the next operation.If he enters any special chararacters like " ?,$,@",or integers, how to validate them. he should not enter any varibles or any special characters. Regards, Harish
-
Hi all, In Dialog based application user has to enter the file name to continue the next operation.If he enters any special chararacters like " ?,$,@",or integers, how to validate them. he should not enter any varibles or any special characters. Regards, Harish
Use the
strtok()
function -
Use the
strtok()
functionstrtok
sucks. It's not thread-safe for a start. It should be avoided.Steve
-
Hi all, In Dialog based application user has to enter the file name to continue the next operation.If he enters any special chararacters like " ?,$,@",or integers, how to validate them. he should not enter any varibles or any special characters. Regards, Harish
reddy harish wrote:
user has to enter the file name
How does he enter the characters ? If it is in a edit box, then I would go for overriding the control. You override the OnChar function, and check first if it the character entered is a valid one (
if ( (NewChar>'a') && (NewChar<'z') )
, of course you have to check for upper case characters also). If the character is valid, then you can call the OnChar function from the base class. If not, don't call the function and the character will never appear in the edit box. This is nicer than validatating the string after inserting all the data. -- modified at 2:31 Wednesday 23rd August, 2006 BTW, did asked a question yesterday about file validating also ? Did you look at the answer of Christian Chraus ? About the CFileDialog[^]? It is in general the way to go when you want the user to open a file. And it is much more user friendly than having the user to enter the complete file or path.
Cédric Moonen Software developer
Charting control [Updated - v1.1] -
strtok
sucks. It's not thread-safe for a start. It should be avoided.Steve
I know it sucks, it's also a nuicance when it comes to UNICODE and MBCS builds, but it's a good starting point for somebody who is learning about string managment.
-
reddy harish wrote:
user has to enter the file name
How does he enter the characters ? If it is in a edit box, then I would go for overriding the control. You override the OnChar function, and check first if it the character entered is a valid one (
if ( (NewChar>'a') && (NewChar<'z') )
, of course you have to check for upper case characters also). If the character is valid, then you can call the OnChar function from the base class. If not, don't call the function and the character will never appear in the edit box. This is nicer than validatating the string after inserting all the data. -- modified at 2:31 Wednesday 23rd August, 2006 BTW, did asked a question yesterday about file validating also ? Did you look at the answer of Christian Chraus ? About the CFileDialog[^]? It is in general the way to go when you want the user to open a file. And it is much more user friendly than having the user to enter the complete file or path.
Cédric Moonen Software developer
Charting control [Updated - v1.1]yes it is an edit box.
-
reddy harish wrote:
user has to enter the file name
How does he enter the characters ? If it is in a edit box, then I would go for overriding the control. You override the OnChar function, and check first if it the character entered is a valid one (
if ( (NewChar>'a') && (NewChar<'z') )
, of course you have to check for upper case characters also). If the character is valid, then you can call the OnChar function from the base class. If not, don't call the function and the character will never appear in the edit box. This is nicer than validatating the string after inserting all the data. -- modified at 2:31 Wednesday 23rd August, 2006 BTW, did asked a question yesterday about file validating also ? Did you look at the answer of Christian Chraus ? About the CFileDialog[^]? It is in general the way to go when you want the user to open a file. And it is much more user friendly than having the user to enter the complete file or path.
Cédric Moonen Software developer
Charting control [Updated - v1.1]Dear Moonen, thanks for ur reply, As iam a begginer of MFC i want to know how to override the control