How to restrict user to Fill only 15 Days back date??
-
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
-
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
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
-
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