By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,700 Members | 1,486 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,700 IT Pros & Developers. It's quick & easy.

function not called from onsubmit code

P: n/a
I have some code comprising the onsubmit attrribute of a form. The code is
executing, but apparently a function called as the last statement is not
executed. The form content is submitted to the server. The behavior is the
same in Firefox and IE (current Windows versions). The following is
excerpted from the browser's "View source":

<script type="text/javascript">
function verify(f)
{
var msg;
var empty_fields = "";
var unselected = "";
var selected = 0;
alert('In verify()'); // not executed
// ...
}
</script>

<form name="ccform" id="ccform" method="post" action="/admin/index.php"
onsubmit="
alert('In onsubmit 1'); // executed
this.type.oneRequired = true;
this.donationtype.oneRequired = true;
this.fname.required = true;
this.lname.required = true;
this.email.required = true;
alert('In onsubmit 2'); // executed
return verify(this);
">

--
For mail, please use my surname where indicated:
st***@surname.reno.nv.us (Steve Brecher)
Jul 8 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Steve Brecher wrote on 08 jul 2006 in comp.lang.javascript:
I have some code comprising the onsubmit attrribute of a form. The
code is executing, but apparently a function called as the last
statement is not executed. The form content is submitted to the
server. The behavior is the same in Firefox and IE (current Windows
versions). The following is excerpted from the browser's "View
source":

<script type="text/javascript">
function verify(f)
{
var msg;
var empty_fields = "";
var unselected = "";
var selected = 0;
alert('In verify()'); // not executed
// ...
}
</script>

<form name="ccform" id="ccform" method="post"
action="/admin/index.php"
onsubmit="
alert('In onsubmit 1'); // executed
It fails in these 5 lines below
this.type.oneRequired = true;
this.donationtype.oneRequired = true;
this.fname.required = true;
this.lname.required = true;
this.email.required = true;
or, deleting them the 3rd alert is shown.
alert('In onsubmit 2'); // executed
return verify(this);
">
<input type=submit>
</form>
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 8 '06 #2

P: n/a
"Steve Brecher" <see.signature@endwrites:
<script type="text/javascript">
function verify(f)
{
var msg;
var empty_fields = "";
var unselected = "";
var selected = 0;
alert('In verify()'); // not executed
None of these lines can fail.
// ...
You have omitted lines here. If one of these lines has a syntax
error, then the entire function declaration fails, and no function
named "verify" is available to be called later.

What errors does the javascript console show?

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 8 '06 #3

P: n/a
Lasse Reichstein Nielsen <lr*@hotpop.comwrote:
You have omitted lines here. If one of these lines has a syntax
error, then the entire function declaration fails, and no function
named "verify" is available to be called later.

What errors does the javascript console show?
It shows a syntax error. Thanks! (Obviously I'm inexperienced with js.)

--
For mail, please use my surname where indicated:
st***@surname.reno.nv.us (Steve Brecher)
Jul 8 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.