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. Date Validation

Date Validation

Scheduled Pinned Locked Moved C / C++ / MFC
question
4 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.
  • R Offline
    R Offline
    Renjith Ramachandran
    wrote on last edited by
    #1

    how can i validate date input from user, i accepts that date in to a CEdit derived control, i want to check whether the user enter the in right format or not ( my required format is DD/MM/YY). any idea ? Thanks in advance Ninety-eight percent of the thrill comes from knowing that the thing you designed works, and works almost the way you expected it would. If that happens, part of you is in that machine.

    D J 2 Replies Last reply
    0
    • R Renjith Ramachandran

      how can i validate date input from user, i accepts that date in to a CEdit derived control, i want to check whether the user enter the in right format or not ( my required format is DD/MM/YY). any idea ? Thanks in advance Ninety-eight percent of the thrill comes from knowing that the thing you designed works, and works almost the way you expected it would. If that happens, part of you is in that machine.

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

      Use CDateTimeCtrl. It can be validated.


      "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

      1 Reply Last reply
      0
      • R Renjith Ramachandran

        how can i validate date input from user, i accepts that date in to a CEdit derived control, i want to check whether the user enter the in right format or not ( my required format is DD/MM/YY). any idea ? Thanks in advance Ninety-eight percent of the thrill comes from knowing that the thing you designed works, and works almost the way you expected it would. If that happens, part of you is in that machine.

        J Offline
        J Offline
        James R Twine
        wrote on last edited by
        #3

        Doing it "old school", you can use a call to sscanf(...), which was designed for scanning a formatted string.  For example, if you would build a string using printf(...) with a format string of "%02d/%02d/%02d", you would scan that string back with that same format string, and check the return value of sscanf(...) to make sure you scanned out three tokens/values.    That would help you verify the format, but not the data... For example, scanning "99/88/77" would be successful, even though it is an invalid date.    Peace! -=- James


        If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
        Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
        DeleteFXPFiles & CheckFavorites

        A 1 Reply Last reply
        0
        • J James R Twine

          Doing it "old school", you can use a call to sscanf(...), which was designed for scanning a formatted string.  For example, if you would build a string using printf(...) with a format string of "%02d/%02d/%02d", you would scan that string back with that same format string, and check the return value of sscanf(...) to make sure you scanned out three tokens/values.    That would help you verify the format, but not the data... For example, scanning "99/88/77" would be successful, even though it is an invalid date.    Peace! -=- James


          If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
          Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
          DeleteFXPFiles & CheckFavorites

          A Offline
          A Offline
          anand_study
          wrote on last edited by
          #4

          A nice article on codeproject site, "editable date time control", using date time edit control and programmer is validating the date based on format, if you check his code, you may get idea about date validation from edit control. Anand

          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