function jm_checkDate(formObj){
        if(/^(\d{2})\/\d{2}\/\d{4}$/.test(thisObj.value)){
                var ProposedDate = new Date(formObj.value);
                var Now = new Date();
                if (ProposedDate > Now){
                        alert("The date you have entered is in the
future.");
                        formObj.focus();
                        return false;
                }else{
                        return true;
                }
        }else{
                alert("Incorrect Date Format.\nDate format should be
mm/dd/yyyy");
                formObj.focus();
                return false;
        }
}

<form name="myform" onsubmit="jm_checkDate(this.form.mydate);">
        <input type="text" name="mydate" value="08/27/2003"
onblur="jm_checkDate(this);">
</form>

You could use either the ONSUBMIT or the ONBLUR depending on when you
want the check to take place.

This function is part of a larger library I wrote that scans all
formfields onsubmit, but in the rare case that I need it to be a
"stand-alone" function it works that way as well.

Thanks, hope this helps.

Joshua Miller
Head Programmer / IT Manager
Garrison Enterprises Inc.
www.garrisonenterprises.net
[EMAIL PROTECTED]
(704) 569-0801 ext. 254
 
************************************************************************
*************
Any views expressed in this message are those of the individual sender,
except where the sender states them to be the views of 
Garrison Enterprises Inc.
 
This e-mail is intended only for the individual or entity to which it is
addressed and contains information that is private and confidential. If
you are not the intended recipient you are hereby notified that any
dissemination, distribution or copying is strictly prohibited. If you 
have received this e-mail in error please delete it immediately and
advise us by return e-mail to [EMAIL PROTECTED]
************************************************************************
*************


-----Original Message-----
From: Jeff [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, August 27, 2003 12:28 PM
To: CF-Talk
Subject: Re: Javascript Date Validation? Anyone know how to approach
this?


on 8/27/03 12:15 PM, Craig Dudley at [EMAIL PROTECTED] wrote:
> For creating your date object from the 3 drop downs, try this....
> 
> New Date(year, month, day, hours, minutes, seconds, ms)
> 
> Use the drop down values for year/month/day and zeros for the others, 
> should give you a date object for your users selection.
> 
> Simply calling 'New Date()' should create another date object with the

> current date and time.
> 
> Date() objects are in ms since epoch (Jan 1 1970 ?) I believe, so make

> sure the 1st date object is one week of milliseconds greater than the 
> current date.
> 
> Any help??

Yikes...you know...I'm not even *sure* if that helps...lol...lemme
re-read it a couple times and get back to you.


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/lists.cfm?link=t:4
Subscription: http://www.houseoffusion.com/lists.cfm?link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Signup for the Fusion Authority news alert and keep up with the latest news in 
ColdFusion and related topics. 
http://www.fusionauthority.com/signup.cfm

Reply via email to