File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes Preventing input type= Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Preventing input type="image" to submit" Watch "Preventing input type="image" to submit" New topic

Preventing input type="image" to submit

Jiri Nejedly
Ranch Hand

Joined: Oct 22, 2002
Posts: 83
Is there any wat to prevent <input type="image"> to submit a form? I tried to add onclick attribute, code from there was run, but form was submitted anyway. Any other chance? Thanks.
Christophe Verré

Joined: Nov 24, 2005
Posts: 14688

Setting onsubmit="return false;" to the form tag ?

[My Blog]
All roads lead to JavaRanch
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
Why make the image a button in the first place, if you don't want it to trigger a form submit?
Jiri Nejedly
Ranch Hand

Joined: Oct 22, 2002
Posts: 83
Long story, all buttons in form are <input type="image"> and all submit this form. Only one new specific button puts some data into opener window and doesn't need to submit.
Never mind. I'll make this specific button an <img>
I agree. Here's the link:
subject: Preventing input type="image" to submit
It's not a secret anymore!