Loading ...
Sorry, an error occurred while loading the content.

Pressing enter twice to submit an autocomplete-enhanced form.

Expand Messages
  • jason.yergeau
    Hi folks, I have a form with an autocomplete text field that suggests matches using the YUI autocomplete widget. I don t want to force the user to select from
    Message 1 of 6 , Oct 24, 2006
    • 0 Attachment
      Hi folks,

      I have a form with an autocomplete text field that suggests matches using the YUI autocomplete widget.  I don't want to force the user to select from one of the matches, which is the default behaviour.

      If a user does not make a selection from the list of matches, or if there are no matches, the form will not be submitted unless the user presses the enter key twice.

      If the user does make a selection, this helped me bypass the second enter stroke:

      autoComplete.itemSelectEvent.subscribe(submitForm);

      I'm still searching for a way to submit the form when the enter key is pressed, and no item is selected.  I tried subscribing a method to the textboxKeyEvent, but it seems carriage returns aren't registered (at least in Firefox).

      Best,
      Jason


    • jennykhan
      Hi Jason, You might try using the Event utility to listen for that DOM event on the input box directly, rather than going through the AutoComplete custom
      Message 2 of 6 , Nov 20, 2006
      • 0 Attachment
        Hi Jason,

        You might try using the Event utility to listen for that DOM event on
        the input box directly, rather than going through the AutoComplete
        custom event.

        Regards,
        Jenny





        --- In ydn-javascript@yahoogroups.com, "jason.yergeau"
        <jason.yergeau@...> wrote:
        >
        > Hi folks,
        >
        > I have a form with an autocomplete text field that suggests matches
        > using the YUI autocomplete widget. I don't want to force the user to
        > select from one of the matches, which is the default behaviour.
        >
        > If a user does not make a selection from the list of matches, or if
        > there are no matches, the form will not be submitted unless the user
        > presses the enter key twice.
        >
        > If the user does make a selection, this helped me bypass the second
        > enter stroke:
        >
        > autoComplete.itemSelectEvent.subscribe(submitForm);
        >
        > I'm still searching for a way to submit the form when the enter key is
        > pressed, and no item is selected. I tried subscribing a method to the
        > textboxKeyEvent, but it seems carriage returns aren't registered (at
        > least in Firefox).
        >
        > Best,
        > Jason
        >
      • cpfs50
        Hi Jenny I also wanted to change the behaviour so that you need only press once to submit the form. Thanks for your help. It works perfectly in
        Message 3 of 6 , Dec 1, 2006
        • 0 Attachment
          Hi Jenny

          I also wanted to change the behaviour so that you need only press
          <RETURN> once to submit the form. Thanks for your help. It works
          perfectly in Firefox, but in IE it seems to miss the first <RETURN>
          key. Here's my code:

          //ensure that any return key submits the form
          var oElement = document.getElementById("ysearchinput0");
          function checkReturn(e) {
          var keyno = YAHOO.util.Event.getCharCode(e);
          if (keyno == 13) {
          document.gensrch.submit();
          }
          }
          YAHOO.util.Event.addListener(oElement, "keypress", checkReturn);

          So basically this functi0n is capturing all keypresses except the
          'first' <RETURN>, keyno 13 in IE but handles it perfectly in Firefox.

          I'd be grateful for any help

          Cheers

          Chris


          --- In ydn-javascript@yahoogroups.com, "jennykhan" <jennyhan@...> wrote:
          >
          > Hi Jason,
          >
          > You might try using the Event utility to listen for that DOM event on
          > the input box directly, rather than going through the AutoComplete
          > custom event.
          >
          > Regards,
          > Jenny
          >
          >
          >
          >
          >
          > --- In ydn-javascript@yahoogroups.com, "jason.yergeau"
          > <jason.yergeau@> wrote:
          > >
          > > Hi folks,
          > >
          > > I have a form with an autocomplete text field that suggests matches
          > > using the YUI autocomplete widget. I don't want to force the user to
          > > select from one of the matches, which is the default behaviour.
          > >
          > > If a user does not make a selection from the list of matches, or if
          > > there are no matches, the form will not be submitted unless the user
          > > presses the enter key twice.
          > >
          > > If the user does make a selection, this helped me bypass the second
          > > enter stroke:
          > >
          > > autoComplete.itemSelectEvent.subscribe(submitForm);
          > >
          > > I'm still searching for a way to submit the form when the enter key is
          > > pressed, and no item is selected. I tried subscribing a method to the
          > > textboxKeyEvent, but it seems carriage returns aren't registered (at
          > > least in Firefox).
          > >
          > > Best,
          > > Jason
          > >
          >
        • jennykhan
          Hi Chris, I believe the problem you are seeing has been fixed as of the latest release. Can you confirm which version you are using? Thanks, Jenny ... user to
          Message 4 of 6 , Dec 5, 2006
          • 0 Attachment
            Hi Chris,

            I believe the problem you are seeing has been fixed as of the latest
            release. Can you confirm which version you are using?

            Thanks,
            Jenny



            --- In ydn-javascript@yahoogroups.com, "cpfs50" <cpfs@...> wrote:
            >
            > Hi Jenny
            >
            > I also wanted to change the behaviour so that you need only press
            > <RETURN> once to submit the form. Thanks for your help. It works
            > perfectly in Firefox, but in IE it seems to miss the first <RETURN>
            > key. Here's my code:
            >
            > //ensure that any return key submits the form
            > var oElement = document.getElementById("ysearchinput0");
            > function checkReturn(e) {
            > var keyno = YAHOO.util.Event.getCharCode(e);
            > if (keyno == 13) {
            > document.gensrch.submit();
            > }
            > }
            > YAHOO.util.Event.addListener(oElement, "keypress", checkReturn);
            >
            > So basically this functi0n is capturing all keypresses except the
            > 'first' <RETURN>, keyno 13 in IE but handles it perfectly in Firefox.
            >
            > I'd be grateful for any help
            >
            > Cheers
            >
            > Chris
            >
            >
            > --- In ydn-javascript@yahoogroups.com, "jennykhan" <jennyhan@> wrote:
            > >
            > > Hi Jason,
            > >
            > > You might try using the Event utility to listen for that DOM event on
            > > the input box directly, rather than going through the AutoComplete
            > > custom event.
            > >
            > > Regards,
            > > Jenny
            > >
            > >
            > >
            > >
            > >
            > > --- In ydn-javascript@yahoogroups.com, "jason.yergeau"
            > > <jason.yergeau@> wrote:
            > > >
            > > > Hi folks,
            > > >
            > > > I have a form with an autocomplete text field that suggests matches
            > > > using the YUI autocomplete widget. I don't want to force the
            user to
            > > > select from one of the matches, which is the default behaviour.
            > > >
            > > > If a user does not make a selection from the list of matches, or if
            > > > there are no matches, the form will not be submitted unless the user
            > > > presses the enter key twice.
            > > >
            > > > If the user does make a selection, this helped me bypass the second
            > > > enter stroke:
            > > >
            > > > autoComplete.itemSelectEvent.subscribe(submitForm);
            > > >
            > > > I'm still searching for a way to submit the form when the enter
            key is
            > > > pressed, and no item is selected. I tried subscribing a method
            to the
            > > > textboxKeyEvent, but it seems carriage returns aren't registered (at
            > > > least in Firefox).
            > > >
            > > > Best,
            > > > Jason
            > > >
            > >
            >
          • cpfs50
            Hi Jenny I m using Yahoo UI Vn 0.12 and the problem is still there. As I mentioned below The behaviour on IE is that the first return entered doesn t seem to
            Message 5 of 6 , Dec 6, 2006
            • 0 Attachment
              Hi Jenny

              I'm using Yahoo UI Vn 0.12 and the problem is still there. As I
              mentioned below The behaviour on IE is that the first return entered
              doesn't seem to fire the checkReturn function shown.
              It's as if autocomplete receives the character first and closes the
              autocomplete ready for the next return to do the form submit, but does
              not allow the Return character to propogate to any other listening
              events.
              The second return does actually arrive in the checkreturn
              function but its too late by then. It seems strange to me that the
              Firefox behaviour is correct and checkReturn gets the first Return
              with no problem. Does Firefox put the addListener event in a different
              order?

              Thanks for any help

              Chris


              --- In ydn-javascript@yahoogroups.com, "jennykhan" <jennyhan@...> wrote:
              >
              > Hi Chris,
              >
              > I believe the problem you are seeing has been fixed as of the latest
              > release. Can you confirm which version you are using?
              >
              > Thanks,
              > Jenny
              >
              >
              >
              > --- In ydn-javascript@yahoogroups.com, "cpfs50" <cpfs@> wrote:
              > >
              > > Hi Jenny
              > >
              > > I also wanted to change the behaviour so that you need only press
              > > <RETURN> once to submit the form. Thanks for your help. It works
              > > perfectly in Firefox, but in IE it seems to miss the first <RETURN>
              > > key. Here's my code:
              > >
              > > //ensure that any return key submits the form
              > > var oElement = document.getElementById("ysearchinput0");
              > > function checkReturn(e) {
              > > var keyno = YAHOO.util.Event.getCharCode(e);
              > > if (keyno == 13) {
              > > document.gensrch.submit();
              > > }
              > > }
              > > YAHOO.util.Event.addListener(oElement, "keypress", checkReturn);
              > >
              > > So basically this functi0n is capturing all keypresses except the
              > > 'first' <RETURN>, keyno 13 in IE but handles it perfectly in Firefox.
              > >
              > > I'd be grateful for any help
              > >
              > > Cheers
              > >
              > > Chris
              > >
              > >
              > > --- In ydn-javascript@yahoogroups.com, "jennykhan" <jennyhan@> wrote:
              > > >
              > > > Hi Jason,
              > > >
              > > > You might try using the Event utility to listen for that DOM
              event on
              > > > the input box directly, rather than going through the AutoComplete
              > > > custom event.
              > > >
              > > > Regards,
              > > > Jenny
              > > >
              > > >
              > > >
              > > >
              > > >
              > > > --- In ydn-javascript@yahoogroups.com, "jason.yergeau"
              > > > <jason.yergeau@> wrote:
              > > > >
              > > > > Hi folks,
              > > > >
              > > > > I have a form with an autocomplete text field that suggests
              matches
              > > > > using the YUI autocomplete widget. I don't want to force the
              > user to
              > > > > select from one of the matches, which is the default behaviour.
              > > > >
              > > > > If a user does not make a selection from the list of matches,
              or if
              > > > > there are no matches, the form will not be submitted unless
              the user
              > > > > presses the enter key twice.
              > > > >
              > > > > If the user does make a selection, this helped me bypass the
              second
              > > > > enter stroke:
              > > > >
              > > > > autoComplete.itemSelectEvent.subscribe(submitForm);
              > > > >
              > > > > I'm still searching for a way to submit the form when the enter
              > key is
              > > > > pressed, and no item is selected. I tried subscribing a method
              > to the
              > > > > textboxKeyEvent, but it seems carriage returns aren't
              registered (at
              > > > > least in Firefox).
              > > > >
              > > > > Best,
              > > > > Jason
              > > > >
              > > >
              > >
              >
            • jennykhan
              Hi Chris, The behavior you describe (if I understand correctly) is as designed: if the container is open and the user selects an item from it, the form is not
              Message 6 of 6 , Dec 13, 2006
              • 0 Attachment
                Hi Chris,

                The behavior you describe (if I understand correctly) is as designed:
                if the container is open and the user selects an item from it, the
                form is not supposed to be submitted. If you would like to change that
                behavior, I recommend subscribing to the itemSelectEvent and calling
                checkReturn when it fires.

                Hope that helps,
                Jenny



                --- In ydn-javascript@yahoogroups.com, "cpfs50" <cpfs@...> wrote:
                >
                > Hi Jenny
                >
                > I'm using Yahoo UI Vn 0.12 and the problem is still there. As I
                > mentioned below The behaviour on IE is that the first return entered
                > doesn't seem to fire the checkReturn function shown.
                > It's as if autocomplete receives the character first and closes the
                > autocomplete ready for the next return to do the form submit, but does
                > not allow the Return character to propogate to any other listening
                > events.
                > The second return does actually arrive in the checkreturn
                > function but its too late by then. It seems strange to me that the
                > Firefox behaviour is correct and checkReturn gets the first Return
                > with no problem. Does Firefox put the addListener event in a different
                > order?
                >
                > Thanks for any help
                >
                > Chris
                >
                >
                > --- In ydn-javascript@yahoogroups.com, "jennykhan" <jennyhan@> wrote:
                > >
                > > Hi Chris,
                > >
                > > I believe the problem you are seeing has been fixed as of the latest
                > > release. Can you confirm which version you are using?
                > >
                > > Thanks,
                > > Jenny
                > >
                > >
                > >
                > > --- In ydn-javascript@yahoogroups.com, "cpfs50" <cpfs@> wrote:
                > > >
                > > > Hi Jenny
                > > >
                > > > I also wanted to change the behaviour so that you need only press
                > > > <RETURN> once to submit the form. Thanks for your help. It works
                > > > perfectly in Firefox, but in IE it seems to miss the first <RETURN>
                > > > key. Here's my code:
                > > >
                > > > //ensure that any return key submits the form
                > > > var oElement = document.getElementById("ysearchinput0");
                > > > function checkReturn(e) {
                > > > var keyno = YAHOO.util.Event.getCharCode(e);
                > > > if (keyno == 13) {
                > > > document.gensrch.submit();
                > > > }
                > > > }
                > > > YAHOO.util.Event.addListener(oElement, "keypress", checkReturn);
                > > >
                > > > So basically this functi0n is capturing all keypresses except the
                > > > 'first' <RETURN>, keyno 13 in IE but handles it perfectly in
                Firefox.
                > > >
                > > > I'd be grateful for any help
                > > >
                > > > Cheers
                > > >
                > > > Chris
                > > >
                > > >
                > > > --- In ydn-javascript@yahoogroups.com, "jennykhan" <jennyhan@>
                wrote:
                > > > >
                > > > > Hi Jason,
                > > > >
                > > > > You might try using the Event utility to listen for that DOM
                > event on
                > > > > the input box directly, rather than going through the AutoComplete
                > > > > custom event.
                > > > >
                > > > > Regards,
                > > > > Jenny
                > > > >
                > > > >
                > > > >
                > > > >
                > > > >
                > > > > --- In ydn-javascript@yahoogroups.com, "jason.yergeau"
                > > > > <jason.yergeau@> wrote:
                > > > > >
                > > > > > Hi folks,
                > > > > >
                > > > > > I have a form with an autocomplete text field that suggests
                > matches
                > > > > > using the YUI autocomplete widget. I don't want to force the
                > > user to
                > > > > > select from one of the matches, which is the default behaviour.
                > > > > >
                > > > > > If a user does not make a selection from the list of matches,
                > or if
                > > > > > there are no matches, the form will not be submitted unless
                > the user
                > > > > > presses the enter key twice.
                > > > > >
                > > > > > If the user does make a selection, this helped me bypass the
                > second
                > > > > > enter stroke:
                > > > > >
                > > > > > autoComplete.itemSelectEvent.subscribe(submitForm);
                > > > > >
                > > > > > I'm still searching for a way to submit the form when the enter
                > > key is
                > > > > > pressed, and no item is selected. I tried subscribing a method
                > > to the
                > > > > > textboxKeyEvent, but it seems carriage returns aren't
                > registered (at
                > > > > > least in Firefox).
                > > > > >
                > > > > > Best,
                > > > > > Jason
                > > > > >
                > > > >
                > > >
                > >
                >
              Your message has been successfully submitted and would be delivered to recipients shortly.