Reset button acting like the submit button

Go To StackoverFlow.com

2

In the script below, the reset button acts also like a submit button. Where could the problem be? Thanks.

HTML

  <input type="image" name="submit" value=" " src="image.png">
  <input type="image" name="reset" value=" " src="reset.png">

Thanks for your time.

2012-04-03 21:21
by NoName
As an aside, reset buttons on forms are so 1990's. Take a look at this article: http://www.useit.com/alertbox/20000416.html and consider not including this clunky thing on your form to start with : - Chris Baker 2012-04-03 21:27


3

Inputs of type image always act like submit buttons.

You can use JavaScript to override the default behaviour, but if the user does not have JavaScript enabled, the button will submit instead of reset.

An option would be to add a regular reset typed button and replace that with an image or image typed input with JavaScript after DOM is loaded. This would make it work on browsers without JavaScript (they get the default reset button) as well as with JavaScript enabled.

2012-04-03 21:26
by Francisc


2

The problem is that by definition

<input type="image" />

defines submit button.

2012-04-03 21:26
by BluesRockAddict


0

That is the intended behavior.

The input element with a type attribute whose value is "image" represents either an image from which the UA enables a user to interactively select a pair of coordinates and submit the form, or alternatively a button from which the user can submit the form.

Source: http://www.w3.org/TR/2012/WD-html-markup-20120329/input.image.html

2012-04-03 21:26
by Tim Medora


0

To make a reset button you should use

<input type="reset" value="Reset">

with type="image" acts like submit button.

2012-04-03 21:29
by The Alpha