Hi
Appreciate your help and advice with the problem I have faced. My code is as follows:
- function Compare() {
-
-
var StartDateSt=document.SearchFrm.startDate.value;
-
var EndDateSt=document.SearchFrm.endDate.value;
-
-
StartDateSt = StartDateSt.split("-");
-
EndDateSt = EndDateSt.split("-");
-
-
var StartDate=new Date();
-
StartDate.setFullYear(StartDateSt);
-
-
var EndDate=new Date();
-
EndDate.setFullYear(EndDateSt);
-
-
alert(EndDate);
-
alert(StartDate);
-
-
}
As the code is run, the two alert boxes return NaN.
Trying to solve the problem in a different way, this time I let the user enter the date the usual way dd/mm/yyyy and use something like :
- var StartDate = new Date(StartDateSt);
-
var StartDateYear = StartDate.getYear();
-
var StartDateMonth = StartDate.getMonth();
-
var StartDateDay = StartDate.getDate();
and then connect the different parts through "-". The problem I face here is that, the entered date in the textbox of my Web page is only processed correctly if it is entered as mm/dd/yyyy; Is this the default setting of dates in Javascript?
How can I change the date format so the user can enter it as dd/mm/yyyy?
Thank you in advance
Maral