RegularExpresionValidator for date

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?QXR1bCBSYW5l?=

    RegularExpresionValidator for date

    I want to restrict user to select received date greater then todays date
    using RegularExpresio nValidator for this i want regular expression.
  • Cor Ligthert [MVP]

    #2
    Re: RegularExpresio nValidator for date

    Atul,

    I am curious, why not normal methods?

    Seems to me a little bit strange, (or your teacher should have asked of
    course this to you, and it is good practise in the .Net newsgroups not to
    help with homework)

    :-)

    Cor

    "Atul Rane" <AtulRane@discu ssions.microsof t.comschreef in bericht
    news:1EC8F48C-2D55-4133-A6D0-18585EA0474C@mi crosoft.com...
    >I want to restrict user to select received date greater then todays date
    using RegularExpresio nValidator for this i want regular expression.

    Comment

    • Alberto Poblacion

      #3
      Re: RegularExpresio nValidator for date

      "Atul Rane" <AtulRane@discu ssions.microsof t.comwrote in message
      news:1EC8F48C-2D55-4133-A6D0-18585EA0474C@mi crosoft.com...
      >I want to restrict user to select received date greater then todays date
      using RegularExpresio nValidator for this i want regular expression.
      Selecting a date "greater than todays date" is going to be very
      difficult with a regular expression. Instead you can use a CompareValidato r,
      which lets you specify a ValueToCompare (that you can set to today's date in
      code), an Operator which you can set to "greater than", and a Type that you
      can set to "Date".

      Comment

      • Hans Kesting

        #4
        Re: RegularExpresio nValidator for date

        It happens that Atul Rane formulated :
        I want to restrict user to select received date greater then todays date
        using RegularExpresio nValidator for this i want regular expression.
        That is impossible: regex knows nothing about "dates" or "numbers", it
        only deals with "strings".

        With a somewhat simple expression you could forbid "very illegal"
        dates, like day 43 or month 21. Using a bit more complex expression you
        can limit days to 1-31 and months to 1-12.
        To recognise the different length of the various maonths requires a
        very complex expression. Leap-years are impossible to detect.

        Hans Kesting


        Comment

        • Duggi

          #5
          Re: RegularExpresio nValidator for date

          On Sep 25, 2:13 am, Atul Rane <AtulR...@discu ssions.microsof t.com>
          wrote:
          I want to restrict user to select received date  greater then todays date
          using RegularExpresio nValidator  for this i want regular expression.
          I think regular expressions Can not compare data... however they
          enforce to be in cetrain format...

          Cor:
          Correct me if I am wrong...

          -Cnu

          Comment

          • Cor Ligthert [MVP]

            #6
            Re: RegularExpresio nValidator for date

            Duggi.

            DateTime.Ticks. ToString() gives a string.
            So it does not look impossible to compare that with Regex,

            However, probably a little bit overdone,

            Cor


            "Duggi" <DuggiSrinivasa Rao@gmail.comsc hreef in bericht
            news:6e5075c1-50ad-4304-89d9-eb97dd8ee106@o4 0g2000prn.googl egroups.com...
            On Sep 25, 2:13 am, Atul Rane <AtulR...@discu ssions.microsof t.com>
            wrote:
            I want to restrict user to select received date greater then todays date
            using RegularExpresio nValidator for this i want regular expression.
            I think regular expressions Can not compare data... however they
            enforce to be in cetrain format...

            Cor:
            Correct me if I am wrong...

            -Cnu


            Comment

            • Hans Kesting

              #7
              Re: RegularExpresio nValidator for date

              Cor Ligthert [MVP] submitted this idea :
              Duggi.
              >
              DateTime.Ticks. ToString() gives a string.
              So it does not look impossible to compare that with Regex,
              >
              However, probably a little bit overdone,
              >
              Cor
              >
              You still can't write a regex to test if a date (whether specified as
              dd-MM-yyyy, MM/dd/yyyy or yyyy/MM/dd) is later than some other date
              (specified in the same syntax or as a 18+ digit number - the result of
              Ticks.ToString( ))

              Hans Kesting

              >
              "Duggi" <DuggiSrinivasa Rao@gmail.comsc hreef in bericht
              news:6e5075c1-50ad-4304-89d9-eb97dd8ee106@o4 0g2000prn.googl egroups.com...
              On Sep 25, 2:13 am, Atul Rane <AtulR...@discu ssions.microsof t.com>
              wrote:
              >I want to restrict user to select received date greater then todays date
              >using RegularExpresio nValidator for this i want regular expression.
              >
              I think regular expressions Can not compare data... however they
              enforce to be in cetrain format...
              >
              Cor:
              Correct me if I am wrong...
              >
              -Cnu

              Comment

              • Cor Ligthert[MVP]

                #8
                Re: RegularExpresio nValidator for date

                Hans,

                ticks are just a long giving the ticks after 01-01-01 (in any time format)

                At that time it was 1 a 10000000th of milliseconds later this was 2.

                Therefore 2 was latter then 1.

                Cor

                "Hans Kesting" <news.hansdk@sp amgourmet.comsc hreef in bericht
                news:uSq9L48HJH A.788@TK2MSFTNG P06.phx.gbl...
                Cor Ligthert [MVP] submitted this idea :
                >Duggi.
                >>
                >DateTime.Ticks .ToString() gives a string.
                >So it does not look impossible to compare that with Regex,
                >>
                >However, probably a little bit overdone,
                >>
                >Cor
                >>
                >
                You still can't write a regex to test if a date (whether specified as
                dd-MM-yyyy, MM/dd/yyyy or yyyy/MM/dd) is later than some other date
                (specified in the same syntax or as a 18+ digit number - the result of
                Ticks.ToString( ))
                >
                Hans Kesting
                >
                >
                >>
                >"Duggi" <DuggiSrinivasa Rao@gmail.comsc hreef in bericht
                >news:6e5075c 1-50ad-4304-89d9-eb97dd8ee106@o4 0g2000prn.googl egroups.com...
                >On Sep 25, 2:13 am, Atul Rane <AtulR...@discu ssions.microsof t.com>
                >wrote:
                >>I want to restrict user to select received date greater then todays date
                >>using RegularExpresio nValidator for this i want regular expression.
                >>
                >I think regular expressions Can not compare data... however they
                >enforce to be in cetrain format...
                >>
                >Cor:
                >Correct me if I am wrong...
                >>
                >-Cnu
                >
                >

                Comment

                • Hans Kesting

                  #9
                  Re: RegularExpresio nValidator for date

                  Cor Ligthert[MVP] wrote :
                  Hans,
                  >
                  ticks are just a long giving the ticks after 01-01-01 (in any time format)
                  >
                  At that time it was 1 a 10000000th of milliseconds later this was 2.
                  >
                  Therefore 2 was latter then 1.
                  >
                  Cor
                  Cor,

                  That is true. But the original question was "how to write a regex to
                  validate that a date is *after today*". So how would you do that if the
                  user had typed in "29-9-2008"?

                  Hans Kesting
                  >
                  "Hans Kesting" <news.hansdk@sp amgourmet.comsc hreef in bericht
                  news:uSq9L48HJH A.788@TK2MSFTNG P06.phx.gbl...
                  >Cor Ligthert [MVP] submitted this idea :
                  >>Duggi.
                  >>>
                  >>DateTime.Tick s.ToString() gives a string.
                  >>So it does not look impossible to compare that with Regex,
                  >>>
                  >>However, probably a little bit overdone,
                  >>>
                  >>Cor
                  >>>
                  >>
                  >You still can't write a regex to test if a date (whether specified as
                  >dd-MM-yyyy, MM/dd/yyyy or yyyy/MM/dd) is later than some other date
                  >(specified in the same syntax or as a 18+ digit number - the result of
                  >Ticks.ToString ())
                  >>
                  >Hans Kesting
                  >>
                  >>
                  >>>
                  >>"Duggi" <DuggiSrinivasa Rao@gmail.comsc hreef in bericht
                  >>news:6e5075 c1-50ad-4304-89d9-eb97dd8ee106@o4 0g2000prn.googl egroups.com...
                  >>On Sep 25, 2:13 am, Atul Rane <AtulR...@discu ssions.microsof t.com>
                  >>wrote:
                  >>>I want to restrict user to select received date greater then todays date
                  >>>using RegularExpresio nValidator for this i want regular expression.
                  >>>
                  >>I think regular expressions Can not compare data... however they
                  >>enforce to be in cetrain format...
                  >>>
                  >>Cor:
                  >>Correct me if I am wrong...
                  >>>
                  >>-Cnu
                  >>
                  >>

                  Comment

                  Working...