# Solved: <input type="image" and ENTER key



## andynic (May 25, 2007)

Hi,

I have a problem with the tag which is a submit button.

When I use "submit" buttons (either type="submit" or type="image") when the user hits the ENTER key, the form does a submit which is not user-friendly in this application.

To get around this, in the case of I have changed them to

Is their some way to prevent the from automatically doing a submit?

Thanks for your help.
Andynic


----------



## allnodcoms (Jun 30, 2007)

Couple of options:

Don't make it a button, just make it an image with an 'onClick' handler.
Supply an 'onKeyPress' handler that does nothing...
I wasn't aware that an image button aromatically got submit status. Odd :roll eyes:...

Is it the only "button" type element in a form?

Danny


----------



## andynic (May 25, 2007)

Hi Danny,
Thanks for your reply.

re. image button and submit:
I also find it odd. Had it functioned as type=" button" there would be no problem in this context at least.
From: http://www.w3schools.com/tags/att_input_type.asp
"image	Defines an image as a submit button"

re. onkeypress: This is a data entry form, so to globally disable keypress is not an option..

re. making it an <img> tag:
This is what I did:








When the user clicks the image, I get to the alert('xxx') but the submit does not function (as it does when it is an tag.
Here is the tag:

The W3 validator does not show any errors.

Thanks for your help.
Andynic


----------



## allnodcoms (Jun 30, 2007)

You need to tell the js what to submit():

```
document.forms["schrijfRecensie"].submit();
```
That should do it...

Danny


----------



## andynic (May 25, 2007)

Thanks for the tip, Danny. It indeed solves the problem.

Thanks again for your help.
Andynic


----------

