Javascript Date Object

C

C

Hi,

I take ina series of date inputs from the user.

I use below JavaScript to parse String into a Date Object
and then I get the Day part and compare the day part.

The date entered for elFPD is 1/1/2003
The date entered for elBalloon is 12/1/2003

The day I get back for elFPD is 3
and teh day I get back for elBalloon is 1.

Anyone know why this is?

MY date settings are English(US)

function CheckDates(){

var elFPD = new Date
(document.frmDefease.txFPD.value);
var elDef = new Date
(document.frmDefease.txDefClose.value);
var elBalloon = new Date
(document.frmDefease.txBalloon.value);


if (elFPD > elBalloon)
{
alert('First Payment Date must not
exceeed Balloon Date');
document.frmDefease.submit=false;
}
else
{

if (elFPD > elDef)
{
alert('First Payment Date
must not exceeed Defeasance Date');

document.frmDefease.submit=false;

}
};

//check Day of FPD against Day of Balloon Date
var FPDDay;
var BalloonDay;
FPDDay = elFPD.getDay();
BalloonDay = elBalloon.getDay();


if(FPDDay != BalloonDay)
{
alert('First Payment Date
day must be the same as Balloon Date day');

}

}
 
D

Dan Brussee

Hi,

I take ina series of date inputs from the user.

I use below JavaScript to parse String into a Date Object
and then I get the Day part and compare the day part.

The date entered for elFPD is 1/1/2003
The date entered for elBalloon is 12/1/2003

The day I get back for elFPD is 3
and teh day I get back for elBalloon is 1.

blah blah blah
//check Day of FPD against Day of Balloon Date
var FPDDay;
var BalloonDay;
FPDDay = elFPD.getDay();
BalloonDay = elBalloon.getDay();


if(FPDDay != BalloonDay)
{
alert('First Payment Date
day must be the same as Balloon Date day');

}

}

Get the ol' Javascript book out I think. The getDay() method of a date
object returns the day of week. 1/1/2003 is a Wednesday (Day number
3), while 12/1/2003 is a Monday (Day number 1). I think what you are
looking for is the getDate() method, which returns the day of month.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top