Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Date Function
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Date Function

 Post Reply Post Reply
Author
maniva View Drop Down
Groupie
Groupie
Avatar

Joined: 04 April 2002
Location: Italy
Status: Offline
Points: 82
Post Options Post Options   Thanks (0) Thanks(0)   Quote maniva Quote  Post ReplyReply Direct Link To This Post Topic: Date Function
    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
Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post 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"

Edited by MorningZ
Contribute to the working anarchy we fondly call the Internet
Back to Top
maniva View Drop Down
Groupie
Groupie
Avatar

Joined: 04 April 2002
Location: Italy
Status: Offline
Points: 82
Post Options Post Options   Thanks (0) Thanks(0)   Quote maniva Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
maniva View Drop Down
Groupie
Groupie
Avatar

Joined: 04 April 2002
Location: Italy
Status: Offline
Points: 82
Post Options Post Options   Thanks (0) Thanks(0)   Quote maniva Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
Bunce View Drop Down
Senior Member
Senior Member
Avatar

Joined: 10 April 2002
Location: Australia
Status: Offline
Points: 846
Post Options Post Options   Thanks (0) Thanks(0)   Quote Bunce Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.