473,383 Members | 1,789 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Trying to check date entered using validation


Trying to check if an entry for an date is < 3 years to current date or
30 days from current date. How can I do this in asp.net....? Do I need

to use the customvalidation. Can anyone give me an example? Thanks in
advance for the help

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #1
5 2266
Hi,

here you have a code snippet:

<asp:TextBox ID="txt" Runat=server></asp:TextBox>
<asp:RangeValidator ID="validDate" Type=Date MinimumValue="2004-10-10"
MaximumValue="2004-10-11" ControlToValidate="txt" EnableClientScript="true"
ErrorMessage="invalid date" Runat=server Display=Dynamic />
<asp:ValidationSummary Runat=server
EnableClientScript=True></asp:ValidationSummary>
<asp:Button Runat=server ></asp:Button>
Now the dates a set static but to change this to make them dynamic add
something like this to the script section of your code:

validDate.MinimumValue = Now.AddYears(-3)
validDateMaximumValue = Now.AddDays(30)

I haven't tested all of this now but the concepts are these...
Bye
Cristian
"TN Bella" <ti********@nav-international.com> wrote in message
news:ux**************@TK2MSFTNGP12.phx.gbl...

Trying to check if an entry for an date is < 3 years to current date or
30 days from current date. How can I do this in asp.net....? Do I need

to use the customvalidation. Can anyone give me an example? Thanks in
advance for the help

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 18 '05 #2
Well that looks good, but can it be globalized?

Date format seem to vary with cultures. So i doubt the hardcoded date format
will
hold when the application should support other cultures.

But you are totally right if globalization is not an issue for the
given product.

Thanks

J.B

"Cristian Suazo" <cristiansuazo @ hotmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hi,

here you have a code snippet:

<asp:TextBox ID="txt" Runat=server></asp:TextBox>
<asp:RangeValidator ID="validDate" Type=Date MinimumValue="2004-10-10"
MaximumValue="2004-10-11" ControlToValidate="txt" EnableClientScript="true" ErrorMessage="invalid date" Runat=server Display=Dynamic />
<asp:ValidationSummary Runat=server
EnableClientScript=True></asp:ValidationSummary>
<asp:Button Runat=server ></asp:Button>
Now the dates a set static but to change this to make them dynamic add
something like this to the script section of your code:

validDate.MinimumValue = Now.AddYears(-3)
validDateMaximumValue = Now.AddDays(30)

I haven't tested all of this now but the concepts are these...
Bye
Cristian
"TN Bella" <ti********@nav-international.com> wrote in message
news:ux**************@TK2MSFTNGP12.phx.gbl...

Trying to check if an entry for an date is < 3 years to current date or
30 days from current date. How can I do this in asp.net....? Do I need

to use the customvalidation. Can anyone give me an example? Thanks in
advance for the help

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!


Nov 18 '05 #3
Wait...I can't use a variable instead so the date doesn't have to be
updated each time in the maximum and minimum value?

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #4
Thanks a bunch..>I am going to test it right now. And no, I don't need
to worry about globalization. I appreciate the input. Thanks again!

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #5


Okay...Thanks Cristian...I just needed to wake up. Thanks a lot for the
help! Here is what was changed:

Private Sub Page_Load
validDate.MinimumValue =
CDate(DateTime.Now.AddYears(-3).ToShortDateString)
validDate.MaximumValue =
CDate(DateTime.Now.AddDays(30).ToShortDateString)
End Sub

Have a great day!
*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

30
by: Dr John Stockton | last post by:
It has appeared that ancient sources give a method for Numeric Date Validation that involves numerous tests to determine month length; versions are often posted by incomers here. That sort of code...
2
by: Lyn | last post by:
Hi, I have a text control on a form which is bound to table field StartDate which is in Date format. When updating the table record via the form, any data entered into the StartDate control is...
3
by: Jake | last post by:
Hi everyone, I am using a popup window to display a calander control. When the user select a date the date on the main window is set to the selected date and the popup closes useing javascript....
7
by: Paul | last post by:
Hi, I have a form where a user is required to enter a start date and an end date. Both are required and must between a specific date range (e.g. 01/01/1900 and 01/01/2099) and the end date...
1
by: TN Bella | last post by:
Hello, I was looking through the older posts for a solution to this problem, but I am still confused on how to fix my problem. There are two dates on my form, one (txtInvDate) is entered by the...
7
by: James P. | last post by:
Hello there, In my asp.net page using VB, I have a date text field in mm/dd/yyyy format. When a date is entered, I'd like to validate it to make sure the date is greater than or equal to the...
6
by: NH | last post by:
I want to allow users to enter dates in a text box in either the US "MM dd yy" format or the UK "dd MM yy" format. But how can I validate these dates? All the date functions e.g. ISdate,...
2
by: John Smith | last post by:
Hello, I have a VB.NET application with a Windows form that have several textboxes fields where I have dates entered. I would like to do a date validation check after the the field is updated, so...
19
Frinavale
by: Frinavale | last post by:
Filtering user input is extremely important for web programming. If input is left unfiltered users can input malicious code that can cripple your website. This article will explain how to make...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.