Use a Submit Button Outside of a Form!

Have you ever felt like you’ve been a professional developer or designer forever, and somehow not known something basic, and borderline hate yourself? That’s me with a trick that was introduced to me by Miguel Piedrafita: ? You can submit forms from a button outside of the form tag by using the form attribute pic.twitter.com/72pjoWu5Ll […]

The post Use a Submit Button Outside of a Form! appeared first on David Walsh Blog.


This content originally appeared on David Walsh Blog and was authored by David Walsh

Have you ever felt like you’ve been a professional developer or designer forever, and somehow not known something basic, and borderline hate yourself? That’s me with a trick that was introduced to me by Miguel Piedrafita:

To submit a form when the button isn’t a child of the parent form, you can use the form attribute:

<form id="myForm">
    <label for="email">Email:</label>
    <input type="email" name="email" placeholder="Email" />
</form>

<!-- Submit button not in parent form! -->
<button type="submit" form="myForm">Submit!</button>

I’m ashamed I didn’t know about this form attribute. In that past I’ve executed CSS magic tricks to accomplish buttons displaying outside of their form area. Did you know about this attribute?!

The post Use a Submit Button Outside of a Form! appeared first on David Walsh Blog.


This content originally appeared on David Walsh Blog and was authored by David Walsh


Print Share Comment Cite Upload Translate Updates
APA

David Walsh | Sciencx (2020-11-24T19:01:46+00:00) Use a Submit Button Outside of a Form!. Retrieved from https://www.scien.cx/2020/11/24/use-a-submit-button-outside-of-a-form/

MLA
" » Use a Submit Button Outside of a Form!." David Walsh | Sciencx - Tuesday November 24, 2020, https://www.scien.cx/2020/11/24/use-a-submit-button-outside-of-a-form/
HARVARD
David Walsh | Sciencx Tuesday November 24, 2020 » Use a Submit Button Outside of a Form!., viewed ,<https://www.scien.cx/2020/11/24/use-a-submit-button-outside-of-a-form/>
VANCOUVER
David Walsh | Sciencx - » Use a Submit Button Outside of a Form!. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2020/11/24/use-a-submit-button-outside-of-a-form/
CHICAGO
" » Use a Submit Button Outside of a Form!." David Walsh | Sciencx - Accessed . https://www.scien.cx/2020/11/24/use-a-submit-button-outside-of-a-form/
IEEE
" » Use a Submit Button Outside of a Form!." David Walsh | Sciencx [Online]. Available: https://www.scien.cx/2020/11/24/use-a-submit-button-outside-of-a-form/. [Accessed: ]
rf:citation
» Use a Submit Button Outside of a Form! | David Walsh | Sciencx | https://www.scien.cx/2020/11/24/use-a-submit-button-outside-of-a-form/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.