473,324 Members | 2,511 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,324 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 1998
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.