Monthly Archives: January 2010

Button type=’button’

Do yourself a big favor… and by ‘yourself’ I mean ‘myself’, and by favor I mean…

When you put a<button> tag on an html document. ALWAYS set the type attribute to ‘button’.

<button type=”button”>Click Me!</button>

Seems redundant, but several browsers are known to treat ALL buttons as type=’submit’. Which can be frustrating when you’ve gone to the trouble of putting a bunch of javascript in to prevent the post back if validation fails.

So basic, yet it still bites me, even after all these years.