How come the first <button> gets activated inside a form?

I have a <form> Inside that form, I have 2 submit buttons.

The first one is this:

<button  class="regular" id="geocodesubmit" style="height:40px;">Set Loc
ation</button>

The second one is this:

<button  type="submit" class="regular" name="Submit Discovery">Submit</button>

How come my first button gets activated when I push enter on one of the text boxes? I want the 2nd one to activate...

I don't want the first one to respond to any keypresses.

Note: I don't want to use input type="submit", because I have a lot of other css stuff.

Answers


The HTML4 spec says that the default type of a button tag is submit. See: http://www.w3.org/TR/html401/interact/forms.html#h-17.5

So your problem is simply the fact, that your first button doesn't have a type attribute and will therefore act like another submit button.

To fix it set type="button" for the first button.


Need Your Help

boost::iterator_adapter not working with STL algorithms

c++ boost stl iterator adaptor

Consider the following "round trip" iterator, which tries to iterate over all the elements in a collection, eventually iterating over the first element again as its final step:

Adding line breaks on “paragraph text” when emailing HTML from google forms response

html google-apps-script google-spreadsheet google-form

I am making a google form that automatically sends out an HTML email upon submission of a new response.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.