Matt RaibleMatt Raible is a Web Developer and Java Champion. Connect with him on LinkedIn.

The Angular Mini-Book The Angular Mini-Book is a guide to getting started with Angular. You'll learn how to develop a bare-bones application, test it, and deploy it. Then you'll move on to adding Bootstrap, Angular Material, continuous integration, and authentication.

Spring Boot is a popular framework for building REST APIs. You'll learn how to integrate Angular with Spring Boot and use security best practices like HTTPS and a content security policy.

For book updates, follow @angular_book on Twitter.

The JHipster Mini-Book The JHipster Mini-Book is a guide to getting started with hip technologies today: Angular, Bootstrap, and Spring Boot. All of these frameworks are wrapped up in an easy-to-use project called JHipster.

This book shows you how to build an app with JHipster, and guides you through the plethora of tools, techniques and options you can use. Furthermore, it explains the UI and API building blocks so you understand the underpinnings of your great application.

For book updates, follow @jhipster-book on Twitter.

10+ YEARS


Over 10 years ago, I wrote my first blog post. Since then, I've authored books, had kids, traveled the world, found Trish and blogged about it all.

HowTo set the default submit button on a form

Howard has a nice little trick for setting the default submit button on a form. Basically, you just put the default button first, and then use style="display: none" to hide it. For the most part, I haven't had any issues with putting the default submit button first (i.e. "Save"), but I have noticed an issue when developing wizards (b/c "« Previous" is likely to be first). Nice tip Howard.

Posted in The Web at Jun 20 2005, 08:58:53 AM MDT 7 Comments
Comments:

Seems like a good try, but fails mildly on accessibility - the button would appear to a non-css-savy accessible browser twice.

Posted by will budreau on May 06, 2006 at 12:00 AM MDT #

This didn't work for me in internet explorer 6.

I used a div with style="display: none" and that worked.

Posted by boris on August 17, 2007 at 12:58 PM MDT #

Wont' work on IE7. Solution is to use same color for text and background of the button as the background of the body.

Posted by pederbl on April 18, 2008 at 11:13 PM MDT #

What about this? <input type="button" name="button_name" onclick="this.form.submit()" value="button_label"> Acting like a submit button, without being one (having the type set). Works for me on IE and Opera. Not tested elsewhere.

Posted by brt on June 12, 2009 at 12:38 AM MDT #

great tip! the only one thing is IE 7 doesn't count the first submit as default if it's "hidden", a little workaround is to position it behind or to the far left, just don't use display:none. The idea of hiding the first submit is awesome though :-)

Posted by m_rahman on January 04, 2010 at 06:15 PM MST #

What about this:

<form>
  <fieldset style="direction:rtl; text-align:left;">
    <input type="submit" name="submit" value="Next" />
    <input type="submit" name="submit" value="Previous" />
  </fieldset>
</form>

This puts the submit buttons in the right order so that 'Next' is the default button, but displays them on the page in the opposite order.

Posted by Splat on October 13, 2010 at 06:20 AM MDT #

Another simple trick

ie 7 and above

create the other button as a type="button" the second can be type="submit"

Something like

<input name="_eventId_cancel" value="   Cancel   " onclick="window.location.href='blahblahh" accesskey="C" tabindex="11" type="button">

<input name="_eventId_save" id="save" value="    Save    " accesskey="C" tabindex="10" type="submit">

Posted by Mantramix on January 18, 2011 at 08:32 AM MST #

Post a Comment:
  • HTML Syntax: Allowed