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: VK <schools_ring@yahoo.com>
Date: Mon Jan 09 2006 - 19:26:13 CET

bdo...@fish.co.uk wrote:
> Thanks for that, but I still have a couple of questions:
>
> 1. Is it not the case that the semantics of onsubmit are such that if
> it returns false the form is not submitted? How does this work if the
> return value is always discarded?
>
> 2. More importantly, is there any way to do what I want to do, namely
> to override onsubmit without losing the return value of the original
> method?

<form method="POST" action="your_URL">

<!-- your form flow -->

<script type="text/javascript">
 var b = '<input type="button" value="Submit" ';
 b+= 'onclick="validate(this.form)">';
 document.write(b);
</script>

<noscript>
<input type = "submit" value="Submit">
</noscript>
</form>

Then later either myForm.submit() or not - depending on form check.
If JavaScript is not enabled then just regular submission w/o
client-side check.

...and be happy ever after :-)

P.S. If document.write() seems to you to be not refined enough for XXI
century :-) you can achieve the same in much more complex but more
"academical" way: still keep the conventional submit button as default
but replace its node on page load with simple button.
Received on Tue Jan 17 17:06:23 2006