48 users online (1 members and 47 guests)  


  Results 1 to 2 of 2
  1. #1
    micho's Avatar
    New User

    Status
    Offline
    Join Date
    Sep 2002
    Location
    Slovenia, Europe
    Posts
    1

    Submitting form without pressing "Enter"

    Hello!
    I would like to know whether is it possible to switch off keypress "Enter" for form submission. The reason I want that is because when I press "Enter" the form resets itself and doesn't do anything. I am working on ASP. I am using <input type=submit> instead.

    Thanks

  2. #2
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    Hiya Micho. Welcome to the forums!

    The 'Enter' option for submitting forms is very much a browser thing, not an HTML thing. However, we should be able to detect how the form was submitted using JavaScript.

    Example Code -
    PHP Code:
    <form name="form1" onSubmit="return false">
    <
    input type="text">
    <
    input type="button" value="SubmitForm" onClick="document.form1.submit()">
    <
    a href="#" onClick="document.form1.submit()"><img src="button.gif"></a>
    </
    form
    This will do nothing when the enter key is pressed, but will submit when 'button.gif' is clicked. Have fun.
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?



Tags for this Thread