A very opinionated form library for Svelte. Currently only supports inputs and textarea.
Usage:
import Form from "svelte-easyforms";
const emailValidator = value =>
/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(
value
);
const inputs = [
{
name: "name",
title: "Who are you ?",
placeholder: "Name, company, etc..."
},
{
name: "email",
title: "What's your email?",
placeholder: "Email...",
type: "email",
validator: emailValidator
},
{
name: "message",
title: "Your message",
placeholder: "Write your message here...",
full: true,
multiline: true
}
];
const submitForm = e => {
console.log("submitForm");
};
And your HTML:
<Form {inputs} buttonText="SEND MESSAGE" on:submit="{submitForm}" reset />
Options: Each input object takes a couple of options
The Form itself takes a number of props: