Re: 'Lost' function return value: what am I doing wrong?
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.javascript archive

Re: 'Lost' function return value: what am I doing wrong?

From: Thomas 'PointedEars' Lahn <PointedEars@web.de>
Date: Mon Jan 09 2006 - 18:18:56 CET

Michael Winter wrote:

> On 09/01/2006 08:12, bdobby@fish.co.uk wrote:
>> I have a form with an onsubmit event handler:
>> <form id="uploadForm" method="post" action="..."
>> onSubmit="checkDates()">
>>
>> The event handler does some minor validation, then returns true or
>> false:
>
> The onsubmit attribute defines - internally - another function. It is
> equivalent to:
>
> document.forms.uploadForm.onsubmit = function(event) {
> checkDates();
> };
>
> As this function does not have a return statement, its result will
> always be the Undefined value (undefined).

True.
 
> <form id="uploadForm" ... onsubmit="return checkDates();">

It is not documented that returning a false-value cancels the event, but it
is documented that a boolean value either cancels or not cancels the event,
depending on the event type. Returning `false' cancels the `submit' event,
`true' does not.

PointedEars
Received on Tue Jan 17 17:06:18 2006