Hi,
Can anybody tell me how to check a date within a Financial year using javascript ?? Suppose I want to validate the date 05/06/2008 within a Fin yr 2008-09.How to go for it ??
Hi,
Can anybody tell me how to check a date within a Financial year using javascript ?? Suppose I want to validate the date 05/06/2008 within a Fin yr 2008-09.How to go for it ??
Subject: Date within a Financial year
I had two fields for date OrderedDate filed and Expected Date Field
the Code take care of following things
date formatt (DD/MM/YYYY)
1 Ordered Date Should not be greater than Expected Date
2 Ordered Date Should not be Less than Current Date
3 There should be 1 Day of gap between OrderedDate and Expected Date
If u carefully go through a code u ll come to know everythng its really simple
// Date Validations started
var dtS = document.forms[0].OrderedDate.value;
var dtE = document.forms[0].ExpectedOn.value;
//Storing year // MM//DD of start Date
var dtSlength = parseInt(dtS.length);
var Syyyy = dtS.substring(6, dtSlength);
var Smm = dtS.substring(3,5);
var Sdd = dtS.substring(0,2);
//Storing year // MM//DD of End Date
var dtElength = parseInt(dtE.length);
var Eyyyy = dtE.substring(6, dtElength);
var Emm = dtE.substring(3,5);
var Edd = dtE.substring(0,2);
//current dates
var thisdate = new Date();
var currdate = thisdate.getDate();
var currMonth = thisdate.getMonth();
var currYear = thisdate.getYear();
var upMonth = parseInt(currMonth) +1 ;
//checking ordered date Vs Current Date
if((Syyyy<currYear) || ((Syyyy==currYear) && (Smm<upMonth)) || (((Syyyy==currYear) && (Smm==upMonth)) && (Sdd<currdate)))
{
alert(“Ordered Date should not be less than current date”);
return false;
}
// checking Ordered Date Vs Expected Date
if(Eyyyy < Syyyy)
{
alert(“Invalid Expected Date Year”)
return false;
}
if((Emm < Smm) && (Eyyyy <=Syyyy))
{
alert(“Invalid Expencted Date Month”);
return false
}
if((Edd< Sdd) && ((Eyyyy <= Syyyy) && (Emm<=Smm)))
{
alert(“Invalid Expected Date”);
return false;
}
if((Edd==Sdd) && ((Eyyyy <= Syyyy) && (Emm<=Smm)))
{
alert(“Expected date should have atlease 1 day of difference”);
return false;
}
}