473,386 Members | 1,766 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,386 software developers and data experts.

date-time validation

Hi,

I have a texbox in a webform that is supposed to hold Dates in a specific
format :
e.g. 20-12-2004

What is the best way to make sure that the entered data is in the correct
format ?

Is there a possibillity to use a special kind of control for that purpose,
as in Winforms where one can use the DateTimePicker.

thnx
Chris
Nov 16 '05 #1
2 2000
Hi Chris,

You can use a RegularExpressionValidador or a customValidator for this.
Or you can do a "similar" thing that in a win. app , instead of
DateTimePicker you can create a popup ( or show a layer ) with an instance
of Calendar this improve the UI of the page too, then you update the TextBox
with the value selected, I'm sure that if you search a little you can find
an example with an explanation of how to do it, if not email me as I do that
in a couple of projects but I have not it in a compact easy to understand
way :).

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Chris" <ch********@pandora.be> wrote in message
news:0t*********************@phobos.telenet-ops.be...
Hi,

I have a texbox in a webform that is supposed to hold Dates in a specific
format :
e.g. 20-12-2004

What is the best way to make sure that the entered data is in the correct
format ?

Is there a possibillity to use a special kind of control for that purpose,
as in Winforms where one can use the DateTimePicker.

thnx
Chris

Nov 16 '05 #2
How about the "official" approach... The CompareValidator determines if
dates, integers, currencies and decimals are in a valid format and it
follows the CultureInfo object associated with the page to determine format.

Set the CompareValidator.Type=Date and Operator=DataTypeCheck.

A web form uses the culture associated with the current thread
(System.Threading.Thread.CurrentThread.CurrentCult ure). So create the
CultureInfo object with its DateTimeFormat property using
ShortDatePattern="MM-dd-yyyy" and DateSeparator="-". You can do this either
at the beginning of Page_Load or in the Global.asax file in the
Application_BeginThread method (if this is a global setting).

FYI: If you are looking for a DateTextBox with popup calendar and supporting
validators that can support this date format, check out my "Peter's Date
Package" at http://www.peterblum.com/datecontrols/home.aspx.

--- Peter Blum
www.PeterBlum.com
Email: PL****@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx
"Chris" <ch********@pandora.be> wrote in message
news:0t*********************@phobos.telenet-ops.be...
Hi,

I have a texbox in a webform that is supposed to hold Dates in a specific
format :
e.g. 20-12-2004

What is the best way to make sure that the entered data is in the correct
format ?

Is there a possibillity to use a special kind of control for that purpose,
as in Winforms where one can use the DateTimePicker.

thnx
Chris

Nov 16 '05 #3

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

Similar topics

2
by: Tjerk | last post by:
Hello all, I have the script below to change an image depending on the date upto january it worked fine but then it just stopped working does anybody have an idea how I can make it work again or...
1
by: Liz Malcolm | last post by:
Hello and TIA. I have a DE form with an option group that if daily is selected todays date is used for start and end date, if weekly is selected Monday - Friday is used. I am trying to add a...
1
by: JonathanParker | last post by:
Another quick one! Trying to search for records by both accounting period and by year in two seperate queries actioned by option buttons. I've sorted the formatting so it's in a UK format but I...
1
by: bhavu10 | last post by:
i got date parameter but it shows only 2007 records and not for other year and would like to know where i have writte code wrong it shows month only from 1/3/2007 to 2/4/2007 not able to figureout...
3
by: JJ | last post by:
Here's the code. $link="http://xbox360cheat.org"; $close_date=$_POST; #last content change check if ($close_date == 0) $close_date = date("Y-m-d H:m:s", mktime(12, 0, 0, date("m"), date...
4
by: Buzby | last post by:
I want a drop down date selection box on a form in the format of Mon 18 June 2007, that will go say 400 days in advance from the current date. Can anyone point me in the right direction as I...
5
by: bruce24444 | last post by:
I have a database which assigns warranty claims to people with a main screen showing number of files assigned to each person. The number assigned shows day, week, month and year numbers so they can...
3
by: Reg143 | last post by:
Hi all, The code below loops from a starting date, incrementing the date and displaying date and day-of-week. Everything is fine until 2007-11-04 is reached. Any help would be appreciated. ...
0
by: jans78 | last post by:
Appreciate if you all can help me to solve my Crystal Report problems First, I create some parameters and one of the parameters is Date. I set the parameter for the date is String. For example :...
8
by: Dr Al | last post by:
I have a table with four date fields, some of which may not be filled in based on our data entry needs. I have a criteria set as <date()-180 which is supposed to pull dates older than 180 days ago....
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
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...

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.