When Is OnSubmit Executed???

Discussion in 'Javascript' started by Robert Nurse, Jun 22, 2004.

  1. Robert Nurse

    Robert Nurse Guest

    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>
    Robert Nurse, Jun 22, 2004
    #1
    1. Advertising

  2. Robert Nurse wrote:

    > 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.


    --
    David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
    Home is where the ~/.bashrc is
    David Dorward, Jun 22, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?U25vd2JhbmsgSmlt?=

    Form-level onSubmit handler

    =?Utf-8?B?U25vd2JhbmsgSmlt?=, Feb 18, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    400
    Peter Blum
    Feb 21, 2004
  2. Replies:
    3
    Views:
    1,112
    bruce barker
    Feb 25, 2004
  3. =?Utf-8?B?Q3Jpc3RpYW4gQ2FybHNzb24=?=

    Re: Add onSubmit To Form?

    =?Utf-8?B?Q3Jpc3RpYW4gQ2FybHNzb24=?=, May 25, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    667
    Steven Cheng[MSFT]
    May 27, 2004
  4. Joeyej
    Replies:
    0
    Views:
    7,949
    Joeyej
    Jun 4, 2004
  5. Mark Rae

    Re: onsubmit Event in aspx page.

    Mark Rae, Aug 17, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    401
    Mark Rae
    Aug 17, 2004
Loading...

Share This Page