Print Page | Close Window

Date Function

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=280
Printed Date: 28 March 2026 at 10:23pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Date Function
Posted By: maniva
Subject: Date Function
Date Posted: 18 February 2003 at 6:14am

I've added two date in a form. The function to check the field in the form is not as but is in javascript.

Now I don't know how :
- To Check if the date are valid 
- To check if the second one is lover than the first one. 

 

Thanks



-------------
Ivano Mangiarotti



Replies:
Posted By: MorningZ
Date Posted: 18 February 2003 at 7:34am
function validateDates() {
    var date1 = document.forms[ 'form name' ][ 'field name 1' ].value;
    var date2 = document.forms[ 'form name' ][ 'field name 2' ].value;

    if IsNaN( new Date(date1) ) {
        //date 1 is not a date
        return false;
        }
    if IsNaN( new Date(date2) ) {
        //date 2 is not a date
        return false;
        }
    if ( new Date(date1) < new Date(date2) ) {
        //Second date is invalid
        return false;
    }
    return true; //Dates Validated
}


want more examples? search google for "javascript date validation"

-------------
Contribute to the working anarchy we fondly call the Internet


Posted By: maniva
Date Posted: 18 February 2003 at 9:43am

Thank you morningZ.

Only a question.
is not possible to use ASP instead javascript in the function to check the form field.

If yes why allways I found javascript ?

Thanks



-------------
Ivano Mangiarotti


Posted By: MorningZ
Date Posted: 18 February 2003 at 9:49am
of course its possible in VBScript (you appeared to ask for javascript in the orginal post)

VBScript version:

<%
Date1 = Request("Field Name Date 1")
Date2 = Request("Field Name Date 2")

if Not IsDate(Date1) then
    'Date 1 is not valid
elseif Not IsDate(Date2) then
    'Date 2 is not valid
elseif Cdate(Date1) < Cdate(Date2) then
    'Date 2 is not less than Date 1
else
    'Dates are valid at this point
end if
%>

-------------
Contribute to the working anarchy we fondly call the Internet


Posted By: maniva
Date Posted: 18 February 2003 at 10:33am

I was asking for javascrip because in all the ASP page provided with Forum or other application I found JSP.

Do you know Why ?


Thank's a lot.



-------------
Ivano Mangiarotti


Posted By: Bunce
Date Posted: 20 February 2003 at 10:34pm

Think you've got that backwards..

The majority of server-side coding in ASP is done using VBScript. If you search the web for samples and tutorials then you'll find that maybe 1 in 10 are written in JScript.

Cheers,
Andrew



-------------
There have been many, many posts made throughout the world...
This was one of them.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net