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#
  4. validate string for special characters

validate string for special characters

Scheduled Pinned Locked Moved C#
question
5 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.
  • I Offline
    I Offline
    iramg
    wrote on last edited by
    #1

    in a textbox when user enter some input after that i want to check wether user enter only alphanumeric values or any special char like *&$@!":. if user does i will inform the user that input string is not valid my question is how i will find out that user has entered special char. reply soon

    S 1 Reply Last reply
    0
    • I iramg

      in a textbox when user enter some input after that i want to check wether user enter only alphanumeric values or any special char like *&$@!":. if user does i will inform the user that input string is not valid my question is how i will find out that user has entered special char. reply soon

      S Offline
      S Offline
      Sean89
      wrote on last edited by
      #2

      string input = textBox.Text;

      if(!input.Contains("@"))
      {
      // do stuff
      }

      Does that help?


      I 1 Reply Last reply
      0
      • S Sean89

        string input = textBox.Text;

        if(!input.Contains("@"))
        {
        // do stuff
        }

        Does that help?


        I Offline
        I Offline
        iramg
        wrote on last edited by
        #3

        so for all special char i have to check seprately. is there is any method to check all of them at once or user would be not able to enter special char thanks

        N E 2 Replies Last reply
        0
        • I iramg

          so for all special char i have to check seprately. is there is any method to check all of them at once or user would be not able to enter special char thanks

          N Offline
          N Offline
          Not Active
          wrote on last edited by
          #4

          Use a regular expression

          only two letters away from being an asset

          1 Reply Last reply
          0
          • I iramg

            so for all special char i have to check seprately. is there is any method to check all of them at once or user would be not able to enter special char thanks

            E Offline
            E Offline
            Ennis Ray Lynch Jr
            wrote on last edited by
            #5

            Override the text box and overrid the following method protected override bool ProcessKeyMessage(ref Message m); There are other ways as well but this one is fairly simple.

            A man said to the universe: "Sir I exist!" "However," replied the Universe, "The fact has not created in me A sense of obligation." -- Stephen Crane

            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