The input form attribute specifies the form the <input> element belongs to. The value of this attribute must be equal to the id attribute of the <form> element it belongs to.
form attribute, an Admin submit button with a custom action URL, a preview button opening in a new tab, and a Draft button that bypasses validation.id="user-form" on form, form="user-form" on outside inputs, formaction for admin submits, formtarget="_blank" for new tabs, and formnovalidate for saving drafts.
<!DOCTYPE html> <html> <head> <title>Multi-Role Portal</title> </head> <body> <h2>User Profile Update</h2> <form action="/update_profile.php" method="get" id="profileForm"> <label for="email">Account Email (Required):</label><br> <input type="email" id="email" name="email" required><br><br> <input type="submit" value="Standard Submit"> <input type="submit" formaction="/admin_override.php" value="Submit to Admin Route"> <input type="submit" formtarget="_blank" value="Preview in New Tab"> <input type="submit" formnovalidate value="Save Draft (Skip Validation)"> </form> <br> <p>This additional field sits outside the main form element:</p> <label for="feedback">User Feedback:</label><br> <input type="text" id="feedback" name="feedback" form="profileForm"> </body> </html>
This additional field sits outside the main form element:
form attribute binds external input fields to a specific form ID. Using formaction changes the backend submission destination dynamically per button. The formtarget="_blank" attribute opens output responses in a separate tab, and formnovalidate allows saving progress without enforcing field checks like required.
formmethod="post" to override default HTTP methods, formenctype="multipart/form-data" for binary uploads on specific buttons, and novalidate inside the main <form> element to turn off validation globally.
<!DOCTYPE html> <html> <head> <title>Job Application Portal</title> </head> <body> <h2>Job Application Portal</h2> <!-- Form uses novalidate to bypass all validation checks globally --> <form action="/submit_app.php" method="get" novalidate> <label for="applicant">Applicant Name:</label><br> <input type="text" id="applicant" name="applicant" required><br><br> <label for="resume">Upload Resume:</label><br> <input type="file" id="resume" name="resume"><br><br> <input type="submit" value="Submit Standard (GET)"> <input type="submit" formmethod="post" value="Submit via Secure POST"> <input type="submit" formmethod="post" formenctype="multipart/form-data" value="Submit with File Payload"> </form> </body> </html>
formmethod attribute overrides the parent form's default HTTP request type (switching from GET to POST for sensitive operations). The formenctype="multipart/form-data" attribute allows file uploads to transmit correctly without altering the form tag itself. Finally, novalidate placed directly inside the <form> element disables client-side validation across all inputs at once.