473,799 Members | 2,666 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 customvalidatio n. 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 2284
Hi,

here you have a code snippet:

<asp:TextBox ID="txt" Runat=server></asp:TextBox>
<asp:RangeValid ator ID="validDate" Type=Date MinimumValue="2 004-10-10"
MaximumValue="2 004-10-11" ControlToValida te="txt" EnableClientScr ipt="true"
ErrorMessage="i nvalid date" Runat=server Display=Dynamic />
<asp:Validation Summary Runat=server
EnableClientScr ipt=True></asp:ValidationS ummary>
<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.Minim umValue = Now.AddYears(-3)
validDateMaximu mValue = Now.AddDays(30)

I haven't tested all of this now but the concepts are these...
Bye
Cristian
"TN Bella" <ti********@n av-international.c om> wrote in message
news:ux******** ******@TK2MSFTN GP12.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 customvalidatio n. 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" <cristiansuaz o @ hotmail.com> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
Hi,

here you have a code snippet:

<asp:TextBox ID="txt" Runat=server></asp:TextBox>
<asp:RangeValid ator ID="validDate" Type=Date MinimumValue="2 004-10-10"
MaximumValue="2 004-10-11" ControlToValida te="txt" EnableClientScr ipt="true" ErrorMessage="i nvalid date" Runat=server Display=Dynamic />
<asp:Validation Summary Runat=server
EnableClientScr ipt=True></asp:ValidationS ummary>
<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.Minim umValue = Now.AddYears(-3)
validDateMaximu mValue = Now.AddDays(30)

I haven't tested all of this now but the concepts are these...
Bye
Cristian
"TN Bella" <ti********@n av-international.c om> wrote in message
news:ux******** ******@TK2MSFTN GP12.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 customvalidatio n. 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.Minim umValue =
CDate(DateTime. Now.AddYears(-3).ToShortDateS tring)
validDate.Maxim umValue =
CDate(DateTime. Now.AddDays(30) .ToShortDateStr ing)
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
3697
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 seems unnecessarily long. For some while, the following approach has been given here :- function ValidDate(y, m, d) { // m = 0..11 ; y m d integers, y!=0
2
2670
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 immediately validated. If the data entered is considered valid, focus moves to the next control in the tab sequence. So far, so good. If the data entered in StartDate is considered invalid, an error message is displayed via MsgBox. When OK is...
3
5272
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. The problem is this bypasses the form validation on the main page and the error message is not dispalyed untill the form is submited. I need to be able to validate the
7
10311
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 cannot preceed the start date. How can I perform the necessary validation using the least number of validation controls. For example is it necessary that I add a requiredfieldvalidator for the start date field and end date field to make sure a value...
1
2851
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 user and has a validator (reDate) attached for specific dates that can be entered. The second date (txtRptDate) is another textbox that is filled with current date, that can not be changed by the user. The date (txtRptDate) that cannot be changed...
7
31846
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 current date. If not, I'd like to display the error message to ValidationSummary. It seems to make sense to me to use CompareValidator but the problem is put the current date into CompareValidator. So, I created a hidden text field in my aspx. ...
6
2894
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, convert.ToDatetime etc fail on the US date format as the application and IIS is set to UK format. Its strange that the date format("12/03/06","MM dd yy") is interpretated correctly but format("12/22/06","MM dd yy") bombs out.
2
6746
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 I' using the leave event. Right now I am creating a 'leave' sub for each of the fields. However, I'd like to simplify that and just call the name of a function and plug the field name as a variable and be done. In other words, I would like...
19
108032
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 sure that the user only submits a number to your .NET web application and also demonstrate how to add JavaScript to your ASPX pages. Upon popular demand, I have added a section that also covers how to use a validator control to check if a text box...
0
9689
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9550
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10495
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10269
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10032
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7573
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6811
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5597
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4148
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.