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. about regular expression validation

about regular expression validation

Scheduled Pinned Locked Moved C#
regexhelptutorial
4 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.
  • A Offline
    A Offline
    abolibapat7
    wrote on last edited by
    #1

    gud afternoon i have a problem i have a taextbox and i want to enter in it only 2 digits or 11 digits example 12 valid 123 invalid 12345678912 valid 123456789123 invalid plz. rply its urgrnt

    M 1 Reply Last reply
    0
    • A abolibapat7

      gud afternoon i have a problem i have a taextbox and i want to enter in it only 2 digits or 11 digits example 12 valid 123 invalid 12345678912 valid 123456789123 invalid plz. rply its urgrnt

      M Offline
      M Offline
      Mohammad Dayyan
      wrote on last edited by
      #2

      You don't need Regex(Regular Expression) Use can use Leave event :

      private void textBox1_Leave(object sender, EventArgs e)
      {
      if (textBox1.Text.Length != 2 && textBox1.Text.Length != 11)
      throw new Exception("invalid");
      }

      modified on Saturday, November 7, 2009 10:03 AM

      P 1 Reply Last reply
      0
      • M Mohammad Dayyan

        You don't need Regex(Regular Expression) Use can use Leave event :

        private void textBox1_Leave(object sender, EventArgs e)
        {
        if (textBox1.Text.Length != 2 && textBox1.Text.Length != 11)
        throw new Exception("invalid");
        }

        modified on Saturday, November 7, 2009 10:03 AM

        P Offline
        P Offline
        PIEBALDconsult
        wrote on last edited by
        #3

        I think you want an &&, not an ||.

        M 1 Reply Last reply
        0
        • P PIEBALDconsult

          I think you want an &&, not an ||.

          M Offline
          M Offline
          Mohammad Dayyan
          wrote on last edited by
          #4

          Yeah, You're right. Thanks

          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