Date Compare

P

Peter

ASP.NET 1.1, this is a Intranet application and runs only on IE.

I have two webform text boxes which contain dates - starting date and ending
date. The dates could be in any format.

for example:
Starting date: 02/15/2006
Ending date: March 2006

I have to make sure the starting date is before the ending date
Because I open Word on the client when client clicks on the submit button I
have to validate these dates on the client.
How can I make sure these dates are in correct range? The CompareVaidator
does not work when starting and ending date are in different format.

The CompareValidator makes the following an invalid
Starting date: 02/15/2006
Ending date: March 2006

but not this:

Starting date: 02/15/2006
Ending date: 03/01/2006

Thank you


Peter
 
S

Steven Cheng[MSFT]

Hi Peter,

Welcome to the ASP.NET newsgroup.

From your description, I understand you have a certain ASP.NET web page
which contain two text field to let user input date time and you need to
compare the date/time in the two text fields. Since the input date's
format in the two text fields may vary, you're wondering a simple and
better means to compare them(the string format ), correct?

Based on my experience, since the input data in the text fields are of text
format and the format of the date/time may also vary, the better approach
maybe postback the page and parse the data in text field into .net DateTime
class instance and do the comparation. Is it posslbe that you do the work
at serverside like this?

For clientside, date/time parsing and format functionality are limited.
There does exists an Date class(javascript class object) which has parse
method and other client script methods, however not all the browsers will
support them. Anyway, here are some web article introduce use the
javascript Date object:

METHOD: Date::parse
http://www.devguru.com/Technologies/ecmascript/quickref/date_parse.html

http://www.comptechdoc.org/independent/web/cgi/javamanual/javadate.html
 
P

Peter

Thank you for your help!

I can not validate on the server because when the user clicks on the submit
button the program opens up a Word document, but I have to make sure the
dates are valid before I can open the Word document. If I do validation on
the server the Word opens up and then I get the error message.
 
S

Steven Cheng[MSFT]

Thanks for your quick response Peter,

Thus, I think you can need to struggle with clientside script api. Anyway,
you can find many web articles over internet newsgroup discussing on
scripting Date/Time data.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top