When Is OnSubmit Executed???

R

Robert Nurse

Hi All,

I'm trying to create a text field that, when two or more characters
are entered, the form is automatically submitted. The trouble I'm
having is knowing when the onSubmit handler is fired. It's supposed
to be executed when the form is submitted. I'm doing a submit via JS
which should cause the form to run the onSubmit handler. But, it
isn't. This leads me to believe that calling submit() is different
from a hard submit. True?


<SCRIPT language="Javascript1.2">
function submitLetters(form, control)
{
var returnValue = true;
if (event.keyCode == 13)
returnValue = false;
else
form.submit();
return returnValue;
}

function CheckFilter(form)
{
var returnValue = true;
alert("length: " + form.nTypeFilter.value.length);
if (form.nTypeFilter.value.length < 2)
returnValue = false;
return returnValue;
}
</SCRIPT>

<FORM name="ByLastName" method="post" onSubmit="return
CheckFilter(this);">
<INPUT type="text" name="nTypeFilter" value="" onKeyPress="return
submitLetters(ByLastName, this);">
</FORM>
 
D

David Dorward

Robert said:
I'm trying to create a text field that, when two or more characters
are entered, the form is automatically submitted. The trouble I'm
having is knowing when the onSubmit handler is fired.

When the user submits the form
I'm doing a submit via JS which should cause the form to run the onSubmit
handler. But, it isn't. This leads me to believe that calling submit()
is different from a hard submit. True?

Yes. Submissions by JS don't trigger the onsubmit event.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top