I load an internal page that I developed in IE and at the bottom it displays some JS error: It says Line 107 character 6. I look at the JScript file and it has this code:
function isLessThanStartDate(obj)
{
var startdate = new Date(document.getElementById('txtSD').value);
var enddate = new Date(obj.value);
var weekending = new Date(document.getElementById('txtWE').value);
if (!(isDate(startdate)))
{
obj.style.backgroundColor="red";
alert (obj.value + " is not a valid date!");
obj.value="";
return;
}
if (enddate < startdate)
{
obj.style.backgroundColor="red";
alert ("End date: " + enddate + " cannot be less then start date: " + startdate);
obj.value="";
}
else if (enddate > weekending)
{
obj.style.backgroundColor="red";
alert ("End date: " + enddate + " cannot be greater then week ending date: " + weekending);
obj.value="";
}
else
{
obj.style.backgroundColor="";
}
}
Line 107 is the line where it says
var weekending = new Date(document.getElementById('txtWE').value);
Why is this complaining? I don't see anything wrong with it...
txtWEandtxtSD- I presume they're input fields). My guess is thatdocument.getElementById('txtWE').valueis failing (possibly a typo in the field name or something?), but I can't be sure without seeing the HTML as well.