How to make submit button without form
HTML5
In HTML5, a has a form attribute. See 4.10 Forms - HTML5.
The form attribute is used to explicitly associate the button element with its form owner.
Example
- Submit
The problem is that doesn't work on IE.
HTML4
Since submit button is a type of control, the submit must appear inside a
. See Forms in HTML documents.The elements used to create controls generally appear inside a FORM element, but may also appear outside of a FORM element declaration when they are used to build user interfaces. This is discussed in the section on intrinsic events. Note that controls outside a form cannot be successful controls.
That said, we can try some things.
Label Element
Something you can do is hide the submit inside a
, and then associate a outside of it. When you click on the text within the element, it toggles the button.But, you can't select the with tab and press space to select, for users that is using the keyboard to naviagate.
JavaScript
You can use JavaScript onclick event.
- Submit
- document.getElementById("submit-button").onclick = function() {
- document.getElementById("form1").submit();
- }
Articoli simili
- How to make the background image of a button disappear when we click it, and make it appear on another button when we click it in Visual Studio
- Why does Android button shape changes but not color after applying background drawable (Android, button, Android drawable, development)?
- How to change a text button in jQuery
- How to create a PHP form that can send user input to my email