IE7 and form submitting

Often, IE7 is regarded less standards compliant than its open source alternatives. Accidentally I ran into a – at least for me – unknown feature in IE7 which proves that in some cases IE7 can be rather strict. Take this, a FORM without a submit-button, but with a BUTTON-button:

<form>
  <!-- a lot of code -->
  <button>fire!</button>
</form>

Firefox just submits the form when you click the button. IE7 however does nothing! It appeared that IE7 only submits the form when the attribute type is specified as type=”submit”.

  <button type="submit">fire!</button>

Cool! Seems logically in the end. Where are the times that Microsoft interpreted all your sloppy code?

Tested with a XHTML 1.0 Strict page with a FORM-element which included three BUTTON-buttons. I encountered no form submitting problems without the type attribute specified  in FF 2.0.0.1 or in Opera 8.54 on Windows XP SP2. I didn’t test in IE6 or other exotic browsers.

7 reacties »

  1. bertt said

    but what is the right behaviour according to the w3c specs?

  2. Alleen jammer dat je het button element niet praktisch (of praktisch niet) kunt gebruiken om formulieren te submitten in IE, aangezien de innerText verstuurd wordt :/

  3. Gaat het om de innerText van het BUTTON-element of om die van alle formuliervelden? In dat laatste geval zou het inderdaad niet werkbaar zijn, maar volgens mij is dat niet zo. Button rules: http://del.icio.us/tomgreuter/button.

  4. Alleen de innerText van de BUTTON inderdaad. En een BUTTON met een IMG werkt dus ook niet fijn.

  5. Volgens mij is er dus alleen een probleem als je met verschillende submitbuttons binnen 1 formulier werkt en je wilt weten welke precies gebruikt is voor submitten. Dit zal meestal niet het geval zijn.

  6. Dan is het inderdaad een probleem.

    IE heeft het trouwens wel verkeerd, aangezien submit de default value is, niet button.

  7. the spec says type=submit is the default value.

    I just ran into this problem myself too. IE7 is clearly violating the spec:

    http://www.w3.org/TR/html401/interact/forms.html#h-17.5

RSS feed for comments on this post · TrackBack URI

Geef een reactie op tom greuter Reactie annuleren