textbox validation

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • computer2580
    New Member
    • Feb 2008
    • 6

    textbox validation

    Hi,

    i have two textboxes one for month(2digits) and one for year(4digits).

    i want to validate them so users cannot input dates in past. what would be a better way of doin this.

    ps. i am a newbie

    thanks
  • Curtis Rutland
    Recognized Expert Specialist
    • Apr 2008
    • 3264

    #2
    Is this ASP.NET, or a windows forms application? You'll handle it differently depending on the situation.

    Originally posted by computer2580
    Hi,

    i have two textboxes one for month(2digits) and one for year(4digits).

    i want to validate them so users cannot input dates in past. what would be a better way of doin this.

    ps. i am a newbie

    thanks

    Comment

    • computer2580
      New Member
      • Feb 2008
      • 6

      #3
      I am using windows forms application

      Comment

      • computer2580
        New Member
        • Feb 2008
        • 6

        #4
        Anyone can help???????

        Comment

        • CyberSoftHari
          Recognized Expert Contributor
          • Sep 2007
          • 488

          #5
          Code:
          if(Convert.Int16(txtDay.text) <= DateTime.Now.Day && Convert.Int16(txtMonth.text) <= DateTime.Now.Month)
          {
          // True Part
          }
          else
          {
          //False part
          }
          }
          DateTime.Now.Mo nth and DateTime.Now.Da y

          Comment

          • computer2580
            New Member
            • Feb 2008
            • 6

            #6
            with above i get this error, any solutions ??

            System.StackOve rflowException was unhandled
            InnerException:

            An unhandled exception of type 'System.StackOv erflowException ' occurred in mscorlib.dll

            Comment

            • Curtis Rutland
              Recognized Expert Specialist
              • Apr 2008
              • 3264

              #7
              System.StackOve rflowException comes from too many nested method calls. You probably have either an infinite loop or infinite recursion somewhere in your program. Look for that. If you can't find it, you'll have to post some of your code.

              Originally posted by computer2580
              with above i get this error, any solutions ??

              System.StackOve rflowException was unhandled
              InnerException:

              An unhandled exception of type 'System.StackOv erflowException ' occurred in mscorlib.dll

              Comment

              Working...