T
Ted Byers
Here is the error:
'edate.value' is null or not an object
I get at this using the debugger presented by MS IE.
Here is how the page/form definition begins:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Campaign Definition</title>
</head>
<body>
<h1>Campaign Configuration</h1>
<br>
<form name='campaign' id='campaign'
action='cgi-bin/create_definition.cgi' method=POST
onSubmit="return verify_data(this)">
<table>
And here are two controls that are used in precisely the same way (at
least on the web page - the differences play out in the perl script
and DB on the server):
<tr>
<td>Campaign start date
</td>
<td>
<input type=text id='sdate' name='sdate' size=10 maxlength=10 />
(format yyyy-mm-dd)
</td>
</tr>
<tr>
<td>Campaign end date
</td>
<td>
<input type=text id='edate' name='edate' size=10 maxlength=10 />
(format yyyy-mm-dd)
</td>
</tr>
And finally, here are the Javascript functions that are in use here
(with the statement where the script dies clearly flagged):
<SCRIPT LANGUAGE="Javascript" type="text/javascript">
function test_date(x) {
var pattern = /\d\d\d\d-\d\d-\d\d/;
if (x.length != 10) return false;
return pattern.test(x);
}
function test_time(x) {
var pattern = /\d\d:\d\d:\d\d/;
if (x.length != 8) return false;
return pattern.test(x);
}
function test_nws(x) {
var pattern = /\w+/;
return !pattern.test(x);
}
function verify_data(f) {
var f1 = test_nws(f.mname.value);
var f2 = test_nws(f.cname.value);
var f3 = test_nws(f.sdate.value);
var f4 = test_nws(f.edate.value);
var f5 = test_nws(f.stime.value);
var f6 = test_nws(f.etime.value);
var f;
var msg = "";
if (f1) {
msg += "You must provide a valid merchant name.\n";
}
if (f2) {
msg += "You must provide a valid campaign name.\n";
}
if (!f3) {
f = test_date(f.sdate.value);
if (!f) {
msg += "The start date provided does not have a recognized
format.\n";
}
} else {
msg += "You must provide a valid start date for your
campaign.\n";
}
if (!f4) {
***********************************************************************************************************
the following statement is where the script apparently dies with the
error: "'edate.value' is null or not an object"
***********************************************************************************************************
f = test_date(f.edate.value);
if (!f) {
msg += "The end date provided does not have a recognized
format.\n";
}
} else {
msg += "You must provide a valid end date for your campaign.
\n";
}
if (!f5) {
f = test_time(f.stime.value);
if (!f) {
msg += "The start time provided does not have a recognized
format.\n";
}
}
if (!f6) {
f = test_time(f.etime.value);
if (!f) {
msg += "The start time provided does not have a recognized
format.\n";
}
}
if (msg) {
alert(msg);
return false;
}
return true;
}
</SCRIPT>
Now the CONSISTENT behaviour is that all the functions used with the
input control sdate work as expected, giving the expected boolean
results for each condition checked for along with the correct contents
for msg.
Further, if edate is empty, I get the correct error message. But when
edate has a value, I get the error message "'edate.value' is null or
not an object".
The inconsistency is that sdate and edate are created and used in
exactly the same way.
It is clear that test_nws is working correctly. It is also clear,
from every condition I test for regarding dates, that test_date works
correctly on sdate. It is likely that test_time works, but I can't
say for certain because the script aborts before getting to it.
Fortunately, the cgi script does nothing at present except echo the
data back to the user in a different format (so I could confirm it was
getting the correct data), and IT seems to be getting whatever data I
give to edate.
I would have expected that if my Javascript or my HTML had an error
related to my checking dates, it would affect both sdate and edate,
but I am baffled as to why only edate is affected.
Any ideas?
Thanks
Ted
'edate.value' is null or not an object
I get at this using the debugger presented by MS IE.
Here is how the page/form definition begins:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Campaign Definition</title>
</head>
<body>
<h1>Campaign Configuration</h1>
<br>
<form name='campaign' id='campaign'
action='cgi-bin/create_definition.cgi' method=POST
onSubmit="return verify_data(this)">
<table>
And here are two controls that are used in precisely the same way (at
least on the web page - the differences play out in the perl script
and DB on the server):
<tr>
<td>Campaign start date
</td>
<td>
<input type=text id='sdate' name='sdate' size=10 maxlength=10 />
(format yyyy-mm-dd)
</td>
</tr>
<tr>
<td>Campaign end date
</td>
<td>
<input type=text id='edate' name='edate' size=10 maxlength=10 />
(format yyyy-mm-dd)
</td>
</tr>
And finally, here are the Javascript functions that are in use here
(with the statement where the script dies clearly flagged):
<SCRIPT LANGUAGE="Javascript" type="text/javascript">
function test_date(x) {
var pattern = /\d\d\d\d-\d\d-\d\d/;
if (x.length != 10) return false;
return pattern.test(x);
}
function test_time(x) {
var pattern = /\d\d:\d\d:\d\d/;
if (x.length != 8) return false;
return pattern.test(x);
}
function test_nws(x) {
var pattern = /\w+/;
return !pattern.test(x);
}
function verify_data(f) {
var f1 = test_nws(f.mname.value);
var f2 = test_nws(f.cname.value);
var f3 = test_nws(f.sdate.value);
var f4 = test_nws(f.edate.value);
var f5 = test_nws(f.stime.value);
var f6 = test_nws(f.etime.value);
var f;
var msg = "";
if (f1) {
msg += "You must provide a valid merchant name.\n";
}
if (f2) {
msg += "You must provide a valid campaign name.\n";
}
if (!f3) {
f = test_date(f.sdate.value);
if (!f) {
msg += "The start date provided does not have a recognized
format.\n";
}
} else {
msg += "You must provide a valid start date for your
campaign.\n";
}
if (!f4) {
***********************************************************************************************************
the following statement is where the script apparently dies with the
error: "'edate.value' is null or not an object"
***********************************************************************************************************
f = test_date(f.edate.value);
if (!f) {
msg += "The end date provided does not have a recognized
format.\n";
}
} else {
msg += "You must provide a valid end date for your campaign.
\n";
}
if (!f5) {
f = test_time(f.stime.value);
if (!f) {
msg += "The start time provided does not have a recognized
format.\n";
}
}
if (!f6) {
f = test_time(f.etime.value);
if (!f) {
msg += "The start time provided does not have a recognized
format.\n";
}
}
if (msg) {
alert(msg);
return false;
}
return true;
}
</SCRIPT>
Now the CONSISTENT behaviour is that all the functions used with the
input control sdate work as expected, giving the expected boolean
results for each condition checked for along with the correct contents
for msg.
Further, if edate is empty, I get the correct error message. But when
edate has a value, I get the error message "'edate.value' is null or
not an object".
The inconsistency is that sdate and edate are created and used in
exactly the same way.
It is clear that test_nws is working correctly. It is also clear,
from every condition I test for regarding dates, that test_date works
correctly on sdate. It is likely that test_time works, but I can't
say for certain because the script aborts before getting to it.
Fortunately, the cgi script does nothing at present except echo the
data back to the user in a different format (so I could confirm it was
getting the correct data), and IT seems to be getting whatever data I
give to edate.
I would have expected that if my Javascript or my HTML had an error
related to my checking dates, it would affect both sdate and edate,
but I am baffled as to why only edate is affected.
Any ideas?
Thanks
Ted