this is what i am trying to do.
Write a simple program that do the following:
1. Accept user input for date in format of (YYYY-MM-DD).
2. Validate YYYY, MM, DD are number.
3. Validate whether this input is a valid date.
4. Print a monthly calendar for the month of the input.

here is my code

<html>
<head>
<title>Calender</title>
</head>
<body>
<table border="1" align=center>
<script type="text/javascript">
	
var Max_day=new Array(31,28,31,30,31,30,31,31,30,31,30,31);
var Max_day=[31,28,31,30,31,30,31,31,30,31,30,31];
var d=new Array(January,February,March,April,May,June,July,August,September,October,November,December);
var d=[January,February,March,April,May,June,July,August,September,October,November,December];
var date=new Date();
var user;
var input=Array();
var true=0;
var day=1;

do
{

	user=Number(prompt("Please insert a date yyyy-mm-dd:"));
		input=user.split("-");	
	if(input[0]%4==0)
		Max_day[1]=29;
	if(input[0]<1 || input[0]>9999 || isNaN(input[0]))
		document.write("Error <br>");
	else if(input[1]<1 || input[1]>12 || isNaN(input[1]))
		document.write("Error <br>");
	else if(input[2]<1 || input[2]>Max_day || isNaN(input[2]))
		document.write("Error <br>");
else
	true=1;
}
	while(true==0)

date.setFullYear(input[0]);
date.setMonth(input[1]-1);

	document.write("<tr>"+date.getFullYear()+" "+d[date.getMonth()]+"</tr>");
	document.write("<tr><td>Sunday</td><td>Monday</td><td>Tuesday</td><td>Wednesday</td><td>Thursday</td><td>Friday</td><td>Saturday</td></tr>");
for(var s=0; s<=7; s++)
{
	document.write("<tr>");
for(var i=0; i<=6; i++)
{
	date.setDate(day);
		if(date.getDay()==x)
		{
			document.write("<td>"+day+"</td>");
			day++;
		}
	else
		document.write("<td></td>");
if(Max_day[input[1]-1<day)
	break;
}
document.write("</tr>");
}
</script>
</table>
</body>
</html>

Why it still cant display
?

i found the problem...

and sorry for annoying

thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.