468,765 Members | 1,506 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,765 developers. It's quick & easy.

Date Compare

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
Feb 15 '06 #1
3 2412
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/...ate_parse.html

http://www.comptechdoc.org/independe.../javadate.html

Feb 16 '06 #2
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.

"Steven Cheng[MSFT]" <st*****@online.microsoft.com> wrote in message
news:AF*************@TK2MSFTNGXA01.phx.gbl...
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/...ate_parse.html

http://www.comptechdoc.org/independe.../javadate.html

Feb 16 '06 #3
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.)

Feb 16 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Richard Hollenbeck | last post: by
4 posts views Thread by Stephen | last post: by
4 posts views Thread by jty202 | last post: by
4 posts views Thread by blini | last post: by
1 post views Thread by Budd | last post: by
12 posts views Thread by Assimalyst | last post: by
reply views Thread by Marin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.