Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to validate the special characters

How to validate the special characters

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    reddy harish
    wrote on last edited by
    #1

    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

    W C 2 Replies Last reply
    0
    • R reddy 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

      W Offline
      W Offline
      Waldermort
      wrote on last edited by
      #2

      Use the strtok() function

      S 1 Reply Last reply
      0
      • W Waldermort

        Use the strtok() function

        S Offline
        S Offline
        Stephen Hewitt
        wrote on last edited by
        #3

        strtok sucks. It's not thread-safe for a start. It should be avoided.

        Steve

        W 1 Reply Last reply
        0
        • R reddy 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

          C Offline
          C Offline
          Cedric Moonen
          wrote on last edited by
          #4

          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]

          R 2 Replies Last reply
          0
          • S Stephen Hewitt

            strtok sucks. It's not thread-safe for a start. It should be avoided.

            Steve

            W Offline
            W Offline
            Waldermort
            wrote on last edited by
            #5

            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.

            1 Reply Last reply
            0
            • C Cedric Moonen

              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]

              R Offline
              R Offline
              reddy harish
              wrote on last edited by
              #6

              yes it is an edit box.

              1 Reply Last reply
              0
              • C Cedric Moonen

                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]

                R Offline
                R Offline
                reddy harish
                wrote on last edited by
                #7

                Dear Moonen, thanks for ur reply, As iam a begginer of MFC i want to know how to override the control

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups