Cluniac
07-30-2003, 03:05 PM
I have discovered a problem with one of my scripts, and I'm wondering if it is a problem with JavaScript itself.
i simplified my code to show directly the problem:
function validatedaterange() {
var begdate = document.getElementById("beg");
var enddate = document.getElementById("end");
//get the values for these 2 fields
var beg = begdate.value;
var end = enddate.value;
var beg1 = parseInt(beg.substr(0,2));
var end1 = parseInt(end.substr(0,2));
if(end1 > beg1){
return true;
}
else{
alert("The ending Date must be later than the beginning Date!");
return false;
}
}
For some reason, for variable "end1", whenever the substring being parsed is "08" or "09", it parses to: 0, and the function returns false. However, if "01", "02", etc. up to 7 is parsed, the number is returned, and the function returns true. 10-12 work fine.
Any suggestions as to why this might be happening?
i simplified my code to show directly the problem:
function validatedaterange() {
var begdate = document.getElementById("beg");
var enddate = document.getElementById("end");
//get the values for these 2 fields
var beg = begdate.value;
var end = enddate.value;
var beg1 = parseInt(beg.substr(0,2));
var end1 = parseInt(end.substr(0,2));
if(end1 > beg1){
return true;
}
else{
alert("The ending Date must be later than the beginning Date!");
return false;
}
}
For some reason, for variable "end1", whenever the substring being parsed is "08" or "09", it parses to: 0, and the function returns false. However, if "01", "02", etc. up to 7 is parsed, the number is returned, and the function returns true. 10-12 work fine.
Any suggestions as to why this might be happening?