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
3 Posts 3 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 How to validate the special characters like %,&,which should not be allowed to enter in the edit control in dialog based application. I need to validate many special characters at a time.how can i validate.

    S D 2 Replies Last reply
    0
    • R reddy harish

      Hi all How to validate the special characters like %,&,which should not be allowed to enter in the edit control in dialog based application. I need to validate many special characters at a time.how can i validate.

      S Offline
      S Offline
      Sebastian Schneider
      wrote on last edited by
      #2

      Either write a filtered edit control (i.e. a control that does not accept certain characters) or filter the string as soon as the user hits "ok" and show him an error, if you find any characters in that field. With std::strings you could use the .find-family of operations. You could, optionally, .remove any characters that you find unsuitable and then write the result back to the editbox, with a message-box for the user showing what he did wrong.

      Cheers, Sebastian -- Contra vim mortem non est medicamen in hortem.

      1 Reply Last reply
      0
      • R reddy harish

        Hi all How to validate the special characters like %,&,which should not be allowed to enter in the edit control in dialog based application. I need to validate many special characters at a time.how can i validate.

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        I suggest either use a masked edit control, or handle the ON_ENCHANGE notification. If any 'invalid' characters are found in the edit control, disable the OK button.


        "Money talks. When my money starts to talk, I get a bill to shut it up." - Frank

        "Judge not by the eye but by the heart." - Native American Proverb

        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