Skip to content

Latest commit

 

History

History
64 lines (51 loc) · 1.34 KB

README.md

File metadata and controls

64 lines (51 loc) · 1.34 KB

Svelte Simple Forms

This is a simple package for client side form validation for svelte and sveltekit without schemas. It has simple syntax for setting up validators for your fields

Usage

import { createForm } from "svelte-simple-forms";

const form = createForm({
		email: {
			email: true,
			required: true
		},
		password: {
			required: true,
			min: 6
		},
        repassword: {
			required: true,
            equalTo: 'password'
		}
	});

	$: {
		form.validate();
	}
<form class="">
    <label>
        Email
        <input type="email" bind:value={form.email} />
            {#each form.errors.email as error}
                <p>{error}</p>
            {/each}
    </label>
    
    <label>
        Passowrd
        <input type="email" bind:value={form.password} />
            {#each form.errors.password as error}
                <p>{error}</p>
            {/each}
    </label>
    
    <label>
        RePassoword
        <input type="email" bind:value={form.repassword} />
            {#each form.errors.repassword as error}
                <p>{error}</p>
            {/each}
    </label>
</form>

You can contribute and report issues at Github.

IMAGE ALT TEXT HERE