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. Date Of Birth

Date Of Birth

Scheduled Pinned Locked Moved C#
regex
6 Posts 6 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.
  • B Offline
    B Offline
    bhanu12345
    wrote on last edited by
    #1

    I am using a textbox which takes date of birth as input I want to use regular expression validator for that textbox The Date Format Should Be mm/dd/yyyy and valid date Can Enyone Hel me Out

    J V G E D 5 Replies Last reply
    0
    • B bhanu12345

      I am using a textbox which takes date of birth as input I want to use regular expression validator for that textbox The Date Format Should Be mm/dd/yyyy and valid date Can Enyone Hel me Out

      J Offline
      J Offline
      Jon Hulatt
      wrote on last edited by
      #2

      http://regexlib.com/

      using System.Beer;

      1 Reply Last reply
      0
      • B bhanu12345

        I am using a textbox which takes date of birth as input I want to use regular expression validator for that textbox The Date Format Should Be mm/dd/yyyy and valid date Can Enyone Hel me Out

        V Offline
        V Offline
        V 0
        wrote on last edited by
        #3

        You can use a Masked Textbox?

        V.
        Stop smoking so you can: Enjoy longer the money you save. Moviereview Archive

        1 Reply Last reply
        0
        • B bhanu12345

          I am using a textbox which takes date of birth as input I want to use regular expression validator for that textbox The Date Format Should Be mm/dd/yyyy and valid date Can Enyone Hel me Out

          G Offline
          G Offline
          Guffa
          wrote on last edited by
          #4

          You can use a pattern like "\d{2}/\d{2}/\d{4}" to validate only the format. You can rule out dates that clearly are invalid with a pattern like "(0[1-9]|[12]\d|3[01])/(0[1-9]|1[0-2])/(19|20)\d\d", but a pattern that would actually check if the date is valid would be extremely complex. Just imagine all the combinations to validate the correct number of days in the different months, then imagine leap years on top of that...

          --- b { font-weight: normal; }

          1 Reply Last reply
          0
          • B bhanu12345

            I am using a textbox which takes date of birth as input I want to use regular expression validator for that textbox The Date Format Should Be mm/dd/yyyy and valid date Can Enyone Hel me Out

            E Offline
            E Offline
            Ed Poore
            wrote on last edited by
            #5

            If you want a regex the following should work \d{2}/\d{2}/\d{4} Not very advanced, just checks for 2 digits followed by a slash and 2 more digits, then a slash then a group of four digits.


            Sig cops got me...

            1 Reply Last reply
            0
            • B bhanu12345

              I am using a textbox which takes date of birth as input I want to use regular expression validator for that textbox The Date Format Should Be mm/dd/yyyy and valid date Can Enyone Hel me Out

              D Offline
              D Offline
              Drew McGhie
              wrote on last edited by
              #6

              If the regex isn't an absolute requirement, look into DateTime.TryParse()

              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