Forms / Validation • Svelte Tutorial
Users are a mischievous bunch, who will submit all kinds of nonsensical data if given the chance. To prevent them from causing chaos, it's important to validate form data. The first line of defense is the browser's built-in form validation, which makes it easy to, for example, mark an as required: Try hitting Enter while the is empty. This kind of validation is helpful, but insufficient. Some validation rules (e.g. uniqueness) can't be expressed using attributes, and in any case, if the user is an elite hacker they might simply delete the attributes using the browser's devtools. To guard against these sorts of shenanigans, you should always use server-side validation. In src/lib/server/database.js, validate that the description exists and is unique: Try submitting a duplicate todo. Yikes! SvelteKit takes us to an unfriendly-looking error page. On the server, we see a 'todos must be unique' error, but SvelteKit hides unexpected error messages from users because t
Forms / Validation • Svelte Tutorial Skip to main content Tutorial Packages Playground Blog Basic Svelte Introduction Welcome to Svelte Your first component Dynamic attributes Styling Nested components HTML tags Reactivity State Deep state Derived state Inspecting state Effects Universal reactivity Props Declaring props Default values Spread props Logic If blocks Else blocks Else-if blocks Each blocks Keyed each blocks Await blocks Events DOM events Inline handlers Capturing Component events Spreading events Bindings Text inputs Numeric inputs Checkbox inputs Select bindings Group inputs Selec
Explore this link on the map →related reading
- Guides: Forms | Next.jsnextjs.org
- Errors and redirects / Basics • Svelte Tutoriallearn.svelte.dev
- How Notion pulled itself back from the brink of failure | Figma Blogfigma.com
- Svelte tutorial note | sung.codessung.codes
- Configuration • SvelteKit Docssvelte.dev
- Introduction / What is SvelteKit? • Svelte Tutoriallearn.svelte.dev
- Overview • Svelte Docssvelte-5-preview.vercel.app
- How building an HTML-first site doubled our users overnightmohkohn.co.uk
- React Form Library | Getting Started Guidesurveyjs.io
- Forms – Reactreactjs.org
- Web standards • SvelteKit Docskit.svelte.dev
- React Form Builder | Generate dynamic HTML forms using JSONsurveyjs.io