rsnext/examples/next-forms/pages/no-js-form.js
Maedah Batool 790db2c2e4
Working example for building forms with Next.js (#32669)
* feat: Forms example

* docs: deploy button

* Update examples/next-forms/package.json

Co-authored-by: Lee Robinson <me@leerob.io>

* Update examples/next-forms/package.json

Co-authored-by: Lee Robinson <me@leerob.io>

* Update examples/next-forms/package.json

Co-authored-by: Lee Robinson <me@leerob.io>

* Update examples/next-forms/pages/js-form.js

Co-authored-by: Lee Robinson <me@leerob.io>

* Update examples/next-forms/pages/js-form.js

Co-authored-by: Lee Robinson <me@leerob.io>

* Update examples/next-forms/pages/index.js

Co-authored-by: Lee Robinson <me@leerob.io>

* Update examples/next-forms/README.md

Co-authored-by: Lee Robinson <me@leerob.io>

* Update comments formatting

* Improve docs for correct examples format.

* Lint tests

Co-authored-by: Lee Robinson <me@leerob.io>
2022-01-17 14:20:50 +01:00

33 lines
1.1 KiB
JavaScript

import Link from 'next/link'
import styles from '../styles/Home.module.css'
export default function Form() {
return (
<div className="container">
<h1 className={styles.title}>
Form{' '}
<Link href="/">
<a>without</a>
</Link>{' '}
JavaScript.
</h1>
<p className={styles.description}>
Get started by looking at{' '}
<code className={styles.code}>pages/no-js-from.js</code>
</p>
{/*action: The action attribute defines where the data gets sent. Its value must be a valid relative or absolute URL. If this attribute isn't provided, the data will be sent to the URL of the page containing the form — the current page.
method: The HTTP method to submit the form with. (case insensitive) s*/}
<form action="/api/form" method="post">
<label htmlFor="first">First Name</label>
<input type="text" id="first" name="first" required />
<label htmlFor="last">Last Name</label>
<input type="text" id="last" name="last" required />
<button type="submit">Submit</button>
</form>
</div>
)
}