diff --git a/docs/guides/building-forms.md b/docs/guides/building-forms.md new file mode 100644 index 0000000000000..59b8d50caf733 --- /dev/null +++ b/docs/guides/building-forms.md @@ -0,0 +1,400 @@ +--- +title: Building Serverless Web Forms with Next.js +description: This guide is tailored at creating serverless web forms with Next.js and Vercel. You'll first learn about the basic form element and then some advanced concepts like how forms are catered in React and finally validation with Next.js serverless functions. +--- + +# Building a Serverless Web Form with Next.js + +A web form has a **client-server** relationship. They are used to send data handled by a web server for processing and storage. The form itself is the client, and the server is any storage mechanism that can be used to store, retrieve and send data when needed. + +This guide will teach you how to create a serverless web form with Next.js (client) and Vercel (server). + +## Part 1: HTML Form + +HTML forms are built using the `
` tag. It takes a set of attributes and fields to structure the form for features like text fields, checkboxes, dropdown menus, buttons, radio buttons, etc. + +Here's the syntax of a HTML form: + +```html + + + + + + + +
+``` + +The front-end looks like this: + +![html forms](https://assets.vercel.com/image/upload/c_scale,w_675/v1643009088/nextjs/guides/building-forms/html-forms.png) + +The HTML `
` tag acts as a container for different `` elements like `text` field and submit `button`. Let's study each of these elements: + +- `action`: An attribute that specifies where the form data is sent when the form is submitted. It's generally a URL (an absolute URL or a relative URL). +- `method`: Specifies the HTTP method, i.e., `GET` or `POST` used to send data while submitting the form. +- `