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. Web Development
  3. ASP.NET
  4. How to restrict user to Fill only 15 Days back date??

How to restrict user to Fill only 15 Days back date??

Scheduled Pinned Locked Moved ASP.NET
helptutorialquestion
3 Posts 2 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.
  • K Offline
    K Offline
    KBM73
    wrote on last edited by
    #1

    Hi, I have one field in which user will fill date for that I have taken One DropDown for "MONTHs" and One TextBox for "DATE" and another TextBox for "YEAR" ("Month/dd/Year"). Now I want to validate Date filled by user..that must be current date or just within 15 days back date. I tried to validate date through range validator(jDateValid) and for that I have written : int curr = DateTime.Now.Day; JDateValid.MinimumValue = Convert.ToString(curr-15); JDateValid.MaximumValue = Convert.ToString(curr); but when the date is 1,2,3,4.....15 range validator giving error message. Anybody help to solve this problem.... KBM

    S 1 Reply Last reply
    0
    • K KBM73

      Hi, I have one field in which user will fill date for that I have taken One DropDown for "MONTHs" and One TextBox for "DATE" and another TextBox for "YEAR" ("Month/dd/Year"). Now I want to validate Date filled by user..that must be current date or just within 15 days back date. I tried to validate date through range validator(jDateValid) and for that I have written : int curr = DateTime.Now.Day; JDateValid.MinimumValue = Convert.ToString(curr-15); JDateValid.MaximumValue = Convert.ToString(curr); but when the date is 1,2,3,4.....15 range validator giving error message. Anybody help to solve this problem.... KBM

      S Offline
      S Offline
      Sun Rays
      wrote on last edited by
      #2

      Hi, on submit button you can check like this. if(DateTime.Parse("Date in string format MM/dd/yyyy") >= DateTime.Now.AddDays(-15) && DateTime.Parse("Date in string format MM/dd/yyyy") <= DateTime.Now) { Label2.Text = "Right"; } else { Label2.Text = "Wrong"; }

      Thanks, Sun Rays Rate this post if you like answer. My Articles

      K 1 Reply Last reply
      0
      • S Sun Rays

        Hi, on submit button you can check like this. if(DateTime.Parse("Date in string format MM/dd/yyyy") >= DateTime.Now.AddDays(-15) && DateTime.Parse("Date in string format MM/dd/yyyy") <= DateTime.Now) { Label2.Text = "Right"; } else { Label2.Text = "Wrong"; }

        Thanks, Sun Rays Rate this post if you like answer. My Articles

        K Offline
        K Offline
        KBM73
        wrote on last edited by
        #3

        Thanks Rays, It is working .....now i am trying to show the error message when condition is false. Thanks again, KBM

        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