Skip to content

FarhanAliRaza/svelte-simple-forms

Repository files navigation

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

About

Easier way to validate forms in svelte. (Not complete)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published