I need to validate the date that has been entered by user...
few thing has to be done here....
1. to validate the format of date
2. to check if the entered date is not gerater than today's date
i have no proble for the firts part....but my problem is in second part....
here is my code...
var myDate = new Date;
myDate.setDate(day); //day is the day from the form
myDate.setMonth(month+1); // month is from the form too
myDate.setFullYear(year); //year from the form
alert("user: "+myDate) //this returns some wrong date...when 30/06/2006 is entered...it alters "wed Mar 2 ...2006"
var today = new Date;
alert("today: "+today) //this returns correct, today's date
if (myDate %26gt; today)
{alert("Date has to be smaller than today's date")}
i tried to use Date.parse also, but couldnt get anything....any idea on this??
if u have any code on this, would be cool too :D:D
(btw...i've already looked online)
tanx alot
Zoha
JavaScript - how do u validate Date in a form?..?
Try:
var myDate=new Date()
myDate.setFullYear(year,month-1,day)
var today = new Date()
if (myDate%26gt;today)
{
Your Message
}
I suppose you can Use the Details given in the Link:
http://www.w3schools.com/js/js_obj_date....
and answer to your particular qustion may be found here:
http://www.irt.org/script/16.htm
Also go to following site for FAQs related to Date
http://www.irt.org/script/date.htm
These might help
crowns
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment