Results 1 to 5 of 5

Thread: Submitting a form by pressing the Enter key

  1. #1
    Join Date
    Dec 2009
    Posts
    66

    Submitting a form by pressing the Enter key

    Hi all,
    I am designing a website for my college project which consists of number of forms. I want that the form should be submitted when the user punches the Enter key instead of clicking the submit button. I tried my best but it works only for a single textfield. It is not working for multiple lines textfields form element. Also explain me how can we make a multiple lines textarea work as single line textfield ?

  2. #2
    Join Date
    Jan 2008
    Posts
    1,521

    Re: Submitting a form by pressing the Enter key

    I am also very much interested in having solutions to this problem. Since i also got stuck to the same problem in my project a few years back. But as far as i remember, Try Using a keyDown Function and try to monitor it for the key 13 and when the key 13 is down call the submit event. A more reliable logic will be appreciated.

  3. #3
    Join Date
    Feb 2008
    Posts
    1,852

    Re: Submitting a form by pressing the Enter key

    This is the code which will solve your problem i.e. You can submit the form by hitting the Enter key try to merge this segment in your code

    <script language="JavaScript" type="text/javascript">
    <!--
    var isShift=null;
    var isNN = (navigator.appName.indexOf("Netscape")!=-1);
    var OP = (navigator.appName.indexOf("Opera")!=-1);
    if(OP)isNN=true;
    var key;
    function shift(event){
    key = (isNN) ? event.which : event.keyCode;
    if (key==16)isShift=1;
    }
    function process(event){
    key = (isNN) ? event.which : event.keyCode;
    if(document.layers&&event.modifiers==4){
    isShift=1;
    }
    if (key==13&&isShift!=1){
    document.Form1.submit();
    }
    if (key!=16)isShift=null;
    }
    function retrieve(){
    document.Form1.txt1.focus();
    if(location.search.length>0){
    blubb=unescape(location.search.split('=')[1]);
    document.Form2.txt2.value=blubb;
    }
    }
    //-->
    </script>

  4. #4
    Join Date
    May 2008
    Posts
    2,389

    Re: Submitting a form by pressing the Enter key

    Firstly I wolud suggest you that you should try out your code using in browsers like IE6 or higher. The old browsers does not allow hitting the enter key to submit the form.


    <form action="FMPro" method="post" name="logForm">
    <input type="hidden" name="-db1" value"Web_TA_Participant_DB.fp5">
    <input type="hidden" name="-lay1" value="Participant Form Part-2">
    <input type="hidden" name="-format1" value="verify_data.htm">
    <input type="hidden" name="-error1" value="log_on_error.htm">

    <!-- The User Name Value="==" CDML make sure that when a search is done on User Name an exact match will be the only result. -->
    <input type="hidden" name="User ID" value="==">

    <div align="center"><font size="+2">
    <input type="text" name="User ID" value="" size=30>
    </font></div>

    <div align="left">
    <input type="submit" name="-find" value="Log-In">
    </div>
    </form>

  5. #5
    Join Date
    Nov 2005
    Posts
    1,323

    Re: Submitting a form by pressing the Enter key

    According to my knowledge I think that you can't submit a form on hitting the Enter key if you have mor than one input field

    let us assume that you have a simple form like this one

    <form action="" method="post">
    <input type="text" />
    </form>

    Now at the time when the focus is set on the input text and you hit the Enter this form will submitted. But if you are having more than one input field, it will not be submitted.

    For example if you consider the following form having two input fields
    1.<form action="" method="post">
    2.<input type="text" name="a" />
    3.<input type="text" name="b" />
    4.</form>

    when you hit enter this form will not be submitted
    you can solve this by adding an invisible item by just including the following segment in your program

    <input type="submit" style="width:0px;height:0px;border:none">

    Hope this would have solved your query

Similar Threads

  1. Benefits of submitting Blogs
    By Ovia in forum Technology & Internet
    Replies: 8
    Last Post: 21-04-2012, 05:53 PM
  2. Scanquery search appears after pressing 'enter' in omnibox
    By Yogisa in forum Technology & Internet
    Replies: 4
    Last Post: 28-08-2011, 10:58 PM
  3. Internet explorer 8:freezes and close enter any URL and press ENTER
    By Niyunki Ji in forum Technology & Internet
    Replies: 3
    Last Post: 07-02-2011, 02:11 PM
  4. Adobe Reader 9.3 crashes when submitting email form
    By Dev-Datta in forum Windows Software
    Replies: 5
    Last Post: 26-06-2010, 12:43 PM
  5. enter key stuck! Unable to <enter> and 'choose' bootmenu
    By royjacob in forum Hardware Peripherals
    Replies: 3
    Last Post: 09-11-2009, 10:50 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,304,474.55383 seconds with 16 queries