Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Future date invalid

Status
Not open for further replies.

arbo80

Programmer
Joined
Jan 5, 2006
Messages
53
Location
US
Hi all,

I have an HTML page and I have a field called Rating Date. I don't want the user to enter a future date. I need a javascript code to allow only past or present date. Unfortunately, I don't really know JS; any tips will be greatly appreciated.

AB
 
something like this (very simple concept - should probably be made more robust with validations, etc...

Code:
function noFutureDate(d) {
    var today = new Date();
    var user_date = new Date(d.value);
        
    if (d.value.length > 0) {
        if (user_date > today) {
            alert("date can't be a future date!");
            d.value = "";
            d.focus();
        }
    }
}



*cLFlaVA
----------------------------
[tt]( <P> <B>)13 * (<P> <.</B>)[/tt]

[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
Thanks, I'll try it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top