1.1.7 • Published 2 years ago

@slimkit-ui/svelte-forms v1.1.7

Weekly downloads
1
License
MIT
Repository
-
Last release
2 years ago

Svelte Forms

Svelte Forms is a lightweight zero dependency libray for handling forms in svelte.

Usage

npm i "@slimkit-ui/svelte-forms"
import { Form, formValidity, validation } from "@slimkit-ui/svelte-forms";

myForm = new Form('customerForm', {
    name: { value: "Thilanka", validation: {minLength: 5, maxLength: 20}},
    email: { value: '', validation: {email:''} }
})

const submitHandler = () => {
        console.log(myForm.name.value);
        console.log(myForm.email.value);
}
<form on:submit|preventDefault={submitHandler} autocomplete="off">
    <label>Full Name: </label>
    <input type="text" use:validation={myForm.name} bind:value={myForm.name.value} />
    {#if myForm.name.showError}
        <p class="help is-danger">Name is invalid</p>
    {/if}

    <label>Email: </label>
    <input type="text" use:validation={myForm.email} bind:value={myForm.email.value} />
    {#if myForm.email.showError}
        <p class="help is-danger">Email is invalid</p>
    {/if}

    <button type="submit"
        disabled={!$formValidity[myForm.formId].isValid}>Submit</button>
</form>

Development

Want to contribute? Great!

Buzz me here thilanka.nuwan89@gmail.com

License

MIT

Free Software, Hell Yeah!

1.1.7

2 years ago

1.1.6

2 years ago

1.1.1

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.0

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

1.0.0-alpha

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago