
Untitled
By: a guest on
May 9th, 2012 | syntax:
None | size: 0.93 KB | hits: 17 | expires: Never
Date validation with switch command does not work
function validateDateFormat(day,month,year) {
alert(month); // this was to ensure month was correct and it is!!
var maxDay = 0;
switch(month)
{
case 01 :
case 03 :
case 05 :
case 07 :
case 08 :
case 10 :
case 12 : maxDay = 31; break;
case 04 :
case 06 :
case 09 :
case 11 : maxDay = 30; break;
case 02 : if(year%4 == 0) maxDay = 29;
else maxDay = 28;
break;
//default : return " Invalid month -"; break;
}
alert(maxDay);
if(day > maxDay) {return " Invalid day -";}
return "";
}
var num = "9";
if (num == 9)
alert("true");
var num = "9";
switch(num) {
case 9:
alert("true");
break;
}
var num = "9";
switch(num) {
case "9": // string
alert("true");
break;
}