I am relatively new to js, but I did think I was starting to get the
hang of it. Then this happened...
I have a form with an onsubmit event handler:
<form id="uploadForm " method="post" action="..."
onSubmit="check Dates()">
The event handler does some minor validation, then returns true or
false:
function checkDates(y, m, d) {
snip<<
if (endDate.getTim e() >= startDate.getTi me())
return true;
alert("Start date must precede end date");
return false;
}
(The arguments to the function are used when it is called elsewhere,
not as onsubmit.)
I also have a library class which needs to process the form submit, so
it hooks onsubmit like this:
MyClass.setOnSu bmit = function(listId ) {
var list = document.getEle mentById(listId );
var form = list.form;
var f = form.onsubmit;
if (typeof f == "function") {
form.oldOnSubmi t = f;
form.onsubmit = function(){
var ok = this.oldOnSubmi t();
if (ok)
return MyClass.onsubmi t(listId);
else
return false;
};
}
else
form.onsubmit = function(){MyCl ass.onsubmit(li stId);};
}
My problem is that the value returned from oldOnSubmit and stored in ok
appears as 'void'. This happens in IE 6 and in FireFox 1.07. Can anyone
explain what's happening?
TIA
Brian