freecoding.school100% FREE · NO SIGNUP
Input HarborISSUE #2 of 46

form attributes · action · method · target

FormaVSCaptain Invalid Input
Forma saysForm attributes control where and how data goes: action, method, target, enctype, and novalidate.

action is the destination URL; method is get (data in the URL, for searches) or post (data in the body, for changes). target can open the response in a new tab. enctype="multipart/form-data" is required when uploading files.

novalidate disables the browser's built-in validation. Get method right first: GET is bookmarkable and idempotent; POST is for anything that creates, changes, or is sensitive.

Power-ups you unlock

Captain Invalid Input attacks — common mistakes

Boss battleSwitch a form between method="get" and method="post" and observe where the submitted data shows up each time.

Example code

<!doctype html>
<html><head><meta charset="utf-8"></head>
<body style="background:#06040d;color:#e6e0ff;font-family:sans-serif;padding:20px">
  <form action="#" method="post" enctype="multipart/form-data">
    <label>file <input type="file" name="upload"></label><br><br>
    <button>upload (post + multipart)</button>
  </form>
</body></html>
▶ Open the interactive comic issue
‹ Forms · The User-Input FrameForm Elements · All The Input Families ›