PDA

View Full Version : onSubmit does not work


ffxkh
11-20-2002, 01:53 PM
Hi,
I tried to use onsubmit for form-Validation. Problem is, the form is always submittet and looks like validation function is never called.

This is my test-html:
-----------------------------------

<FORM NAME="onSubmitTest" ACTION="nopage.html" METHOD="post" onSubmit="return chk_filename(this.form.Dateiname);">
<INPUT class="text" type=FILE size=80 name="Dateiname" />
<INPUT TYPE="submit" onSubmit="return chk_filename(this.form.Dateiname);">
</FORM>

<script language=JavaScript>
function chk_filename(Fieldname)
{
return false;
}
</script>
--------------------------------------------------------
Using OnClick instead of inSubmit works perfect (?)

Thanks for help

Dalziel
11-20-2002, 01:56 PM
Why not just put the form tag as this:

<form onsubmit="return false">

That should work fine (obviously add your name and action to the tag as well)

ffxkh
11-20-2002, 02:04 PM
THAT works, but a function-call does not. That's my Problem. :)

RadarBob
11-20-2002, 02:11 PM
Originally posted by Dalziel
Why not just put the form tag as this:

<form onsubmit="return false">

That should work fine (obviously add your name and action to the tag as well)

I understand that you've put that in there for testing/troubleshooting ....

Your call is odd.

onSubmit="return chk_filename(this.form.Dateiname);"


I'd try this, with ".form":

onSubmit="return chk_filename(this.Dateiname);">


Since the call is inside the <form> tag, "this" is the form.

ffxkh
11-20-2002, 02:23 PM
I tried "this.Dateiname" instead of "this.form.Dateiname".
Same Effect, no function call.

I also tried a function-Call without any Parameters... same effect.

Dalziel
11-20-2002, 02:45 PM
:rolleyes:

RadarBob
11-20-2002, 04:10 PM
I'm reaching here...

remove the "onsubmit" from the submit button. Have it only in the <form> tag.

Double-check your typing. Javascript is case sensitive.

Put alert()s in your function to trace execution.

If after all that it's still not working try calling with an explict form-name reference:

<FORM NAME="onSubmitTest" ACTION="nopage.html"
METHOD="post"
onSubmit="return chk_filename(onSubmitTest.Dateiname);">