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. check format of date input

check format of date input

Scheduled Pinned Locked Moved C#
questionhelp
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
    rcwoods
    wrote on last edited by
    #1

    hi How do i go about checking the format of the date that a user entered in a textbox? The date will be their date of birth. I want to make sure it is a valid date. Please someone help me.

    J 1 Reply Last reply
    0
    • R rcwoods

      hi How do i go about checking the format of the date that a user entered in a textbox? The date will be their date of birth. I want to make sure it is a valid date. Please someone help me.

      J Offline
      J Offline
      Judah Gabriel Himango
      wrote on last edited by
      #2

      DateTime date;
      bool isValidDate = DateTime.TryParse(userInputString, out date);

      There are also regular expressions, but DateTime.TryParse may suit you just fine.

      Tech, life, family, faith: Give me a visit. I'm currently blogging about: And in this corner, the Party of Allah The apostle Paul, modernly speaking: Epistles of Paul Judah Himango

      G 1 Reply Last reply
      0
      • J Judah Gabriel Himango

        DateTime date;
        bool isValidDate = DateTime.TryParse(userInputString, out date);

        There are also regular expressions, but DateTime.TryParse may suit you just fine.

        Tech, life, family, faith: Give me a visit. I'm currently blogging about: And in this corner, the Party of Allah The apostle Paul, modernly speaking: Epistles of Paul Judah Himango

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

        Judah Himango wrote:

        There are also regular expressions

        I wouldn't like to try to write a regular expression that can check if a date is valid. Just the expression to check for the different number of days in the months would be horrific, not to speak of leap years... :)

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

        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